PYTHON SCRIPT/SCHEME EXCHANGE

Users who are viewing this thread

That's a very smart method. I made an anti import system once, by saving and comparing the stats of player troop, but now I find your method is much simpler and stronger approach.
 
Hey guys.I have wrote an code.With this code,you can give extra tax to your troop for rising morale :smile:

In the modulge_game_menus,below or above this code;

Code:
("camp_action",[],"Take an action.",
       [(jump_to_menu, "mnu_camp_action"),
        ]
       ),

Paste this;

Code:
###Camping Moraller
	  ("camp_moraling",[],"Give extra tax to your troops",
	  [(jump_to_menu, "mnu_camp_moraling"),
	  ]
	 ),
###Camping Moraller ends

And before the last bracket (  "]"  ),add that menu's;
Code:
###Camping moraller  
  ("camp_moraling",0,
   "Give extra tax to your troops for their morales:",
   "none",
   [
     ],
    [
      ("big_tax",[(store_troop_gold,":total_money","trp_player"),(gt, ":total_money",1500)],"Give Full tax(a great morale)",
       [(troop_remove_gold, "trp_player", 1500),
	    (party_set_morale, "p_main_party", 40),
        ]
       ),
      ("medium_tax",[(store_troop_gold,":total_money","trp_player"),(gt, ":total_money",750)],"Give Medium tax(middle morale)",
       [(troop_remove_gold, "trp_player", 750),
	    (party_set_morale, "p_main_party", 20),
        ]
       ),
      ("low_tax",[(store_troop_gold,":total_money","trp_player"),(gt, ":total_money",500)],"Give low tax(low morale)",
       [(troop_remove_gold, "trp_player", 500),
	    (party_set_morale, "p_main_party", 10),
        ]
       ),
      ("camp_action_4",[],"Back to camp menu.",
       [(jump_to_menu, "mnu_camp"),
        ]
       ),
      ]
  ),
###Camping moraller Ends

Also,if you havent enough money,this menus will not visible. :smile:
 
Your script will override the daily morale adjustment, effectively making your party disregard the lack of food or hundreds of people in the party. Consider setting a global from your menu and then adjusting get_player_party_morale_values as necessary, resetting it from the 24-hour simple trigger.
 
okay.I made something like that;

Code:
(store_random_in_range, ":morale_increase", 20 * 1, 20 * 2),
                    (call_script, "script_change_player_party_morale", ":morale_increase"),
I think thats giving morale between 20-40.
Should i add that instead this code?;
Code:
(party_set_morale, "p_main_party", 40),
 
Here is a nifty small mission trigger, which decreases your relationship with the lord/king and with its faction in a battle once you kill it.

Code:
 #Belendor - Every killing of a lord or king decreases your relationship with corresponding faction and person himself.
common_lord_trigger = (
  ti_on_agent_killed_or_wounded, 0, 0, [],
  [
    (store_trigger_param_1, ":killed_agent"),
    (store_trigger_param_2, ":killer_agent"),

    (get_player_agent_no, ":player"),

    (agent_is_active, ":killed_agent"),
    (agent_is_active, ":killer_agent"),
    (agent_is_alive, ":killer_agent"),
    
     (agent_get_troop_id, ":killed_trp", ":killed_agent"),
     (troop_is_hero, ":killed_trp"),
    
     (eq, ":killer_agent", ":player"),
     
     (store_random_in_range, ":lord_num", -5, -10),
     (store_random_in_range, ":lord_fac_num", -2, -5),
     (store_random_in_range, ":king_num", -3, -8),
     (store_random_in_range, ":king_fac_num", -1, -3),
    
     (try_begin),
     (is_between, ":killed_trp", lords_begin, lords_end),
      (assign, ":rep_to_dec", ":lord_num"),
      (assign, ":fac_rep_to_dec", ":lord_fac_num"),
     (else_try),
     (is_between, ":killed_trp", kings_begin, kings_end),
      (assign, ":rep_to_dec", ":king_num"),
      (assign, ":fac_rep_to_dec", ":king_fac_num"),
     (try_end),
      
     (call_script, "script_change_player_relation_with_troop", ":killed_trp", ":fac_rep_to_dec"),
      (store_troop_faction, ":killed_trp_fac", ":killed_trp"),
     (call_script, "script_change_player_relation_with_faction_ex", ":killed_trp_fac", ":rep_to_dec"),
    ])
 
  (ti_on_agent_killed_or_wounded, 0, 0,
  [(store_trigger_param_1, ":victim"),
    (store_trigger_param_2, ":killer"),
    (store_trigger_param_3, ":is_wounded"),
    (agent_get_troop_id, ":victim_troop", ":victim"),
    (agent_get_troop_id, ":killer_troop", ":killer"),
    (try_begin),
    (eq, ":killer_troop", "trp_player"),
    (set_show_messages, 0),
    (store_character_level, ":victim_lvl", ":victim_troop"),
    (store_add, ":eek:ld_xp", ":victim_lvl", 10),
    (val_mul, ":eek:ld_xp", ":eek:ld_xp"),
    (val_div, ":eek:ld_xp", 5),
    (val_sub, ":eek:ld_xp", 1),
    (assign, ":new_xp", ":eek:ld_xp"),
      [then increase new_xp any way you want as long as you are using val_xxx ops instead of store_xxx]
(assign, reg3, ":eek:ld_xp"),
    (assign, reg2, ":new_xp"),
    (str_clear, s0),
    (str_clear, s1),
    (str_clear, s2),
    (str_store_troop_name, s0, ":victim_troop"),
    (str_store_troop_name, s1, ":killer_troop"),
      (try_begin),
      (eq, ":is_wounded", 0),
      (str_store_string, s2, "@killed"),
      (else_try),
      (eq, ":is_wounded", 1),
      (str_store_string, s2, "@knocked unconscious"),
      (try_end),
    (store_sub, ":diff", reg2, reg3),
    (add_xp_to_troop, ":diff", "trp_player"),
(assign, "$player_has_recently_made_a_kill", 1),
    (try_end),
],
  [],
  ),
 
(0, 0, 0, [],
[(eq, "$player_has_recently_made_a_kill", 1),
(set_show_messages, 1),
(assign, "$player_has_recently_made_a_kill", 0),
(display_message, "@{s0} {s2} by {s1}", 0x008080), # a bit darker than the normal lovely teal text, but still
(display_message, "@You got {reg2} experience"),
]),
PS. I've made some changes to the anti-cheat code to fix the issue I mentioned in hidden text in my previous post:

  ["anti_cheat","Anti-Cheat","Anti-Cheat",tf_hero|tf_unmoveable_in_party_window,0,reserved,fac_player_faction,
  [],
  str_5|agi_5|int_5|cha_5,wp(40),0,0x000000018000000136db6db6db6db6db00000000001db6db0000000000000000],
  #script_game_get_statistics_line:
  # This script is called from the game engine when statistics page is opened.
  # INPUT:
  # param1: line_no
  ("game_get_statistics_line",
    [
      (store_script_param_1, ":line_no"),
      (try_begin),
        (eq, ":line_no", 0),
        (get_player_agent_kill_count, reg1),
        (str_store_string, s1, "str_number_of_troops_killed_reg1"),
        (set_result_string, s1),
      (else_try),
        (eq, ":line_no", 1),
        (get_player_agent_kill_count, reg1, 1),
        (str_store_string, s1, "str_number_of_troops_wounded_reg1"),
        (set_result_string, s1),
      (else_try),
        (eq, ":line_no", 2),
        (get_player_agent_own_troop_kill_count, reg1),
        (str_store_string, s1, "str_number_of_own_troops_killed_reg1"),
        (set_result_string, s1),
      (else_try),
        (eq, ":line_no", 3),
        (get_player_agent_own_troop_kill_count, reg1, 1),
        (str_store_string, s1, "str_number_of_own_troops_wounded_reg1"),
        (set_result_string, s1),
      (try_end),
  #####################################################  
  (try_begin),
  (eq, "$player_char_window_opened", 1),
  (assign, "$return_from_stats_page", 1),
          (set_player_troop, "trp_anti_cheat"),
  (try_end),
  #####################################################

  ]),

("init_anti_import",
    [  
      (store_script_param_1, ":troop_no"),
        (try_begin),
(this_or_next|eq, ":troop_no", "trp_player"),
        (eq, ":troop_no", "trp_anti_cheat"),
        (assign, "$player_char_window_opened", 1),
        (try_begin),
(eq, "$return_from_stats_page", 1),
        (set_player_troop, "trp_player"),
(assign, "$return_from_stats_page", 0),
(try_end),
(else_try),
(assign, "$player_char_window_opened", 0),
        (try_end),
      ]),
 
Here is some rather simple code to make unique map icons for each faction, rather than a generic "flagbearer" icon.

  # script_create_kingdom_hero_party
  # Input: arg1 = troop_no, arg2 = center_no
  # Output: $pout_party = party_no
  ("create_kingdom_hero_party",
    [
      (store_script_param, ":troop_no", 1),
      (store_script_param, ":center_no", 2),

      (store_troop_faction, ":troop_faction_no", ":troop_no"),

      (assign, "$pout_party", -1),
      (try_begin),
        (eq, "$g_there_is_no_avaliable_centers", 0),
      (set_spawn_radius, 0),
  (else_try),
        (set_spawn_radius, 15),
      (try_end),
      (spawn_around_party, ":center_no", "pt_kingdom_hero_party"),

      (assign, "$pout_party", reg0),

      (party_set_faction, "$pout_party", ":troop_faction_no"),
      (party_set_slot, "$pout_party", slot_party_type, spt_kingdom_hero_party),
      (call_script, "script_party_set_ai_state", "$pout_party", spai_undefined, -1),
      (troop_set_slot, ":troop_no", slot_troop_leaded_party, "$pout_party"),
      (party_add_leader, "$pout_party", ":troop_no"),
      (str_store_troop_name, s5, ":troop_no"),
      (party_set_name, "$pout_party", "str_s5_s_party"),

      (party_set_slot, "$pout_party", slot_party_commander_party, -1), #we need this because 0 is player's party!

      #Setting the flag icon
      #normal_banner_begin
      (troop_get_slot, ":cur_banner", ":troop_no", slot_troop_banner_scene_prop),
      (try_begin),
        (gt, ":cur_banner", 0),
        (val_sub, ":cur_banner", banner_scene_props_begin),
        (val_add, ":cur_banner", banner_map_icons_begin),
        (party_set_banner_icon, "$pout_party", ":cur_banner"),
      #custom_banner_begin
      #(troop_get_slot, ":flag_icon", ":troop_no", slot_troop_custom_banner_map_flag_type),
      #(try_begin),
      #  (ge, ":flag_icon", 0),
      #  (val_add, ":flag_icon", custom_banner_map_icons_begin),
      #  (party_set_banner_icon, "$pout_party", ":flag_icon"),
      (try_end),
(try_begin),
(eq, ":troop_faction_no", "fac_kingdom_1"),
(party_set_icon, "$pout_party", "icon_dedal_map_swadia_lord_a"),
(else_try),
(eq, ":troop_faction_no", "fac_kingdom_2"),
(party_set_icon, "$pout_party", "icon_dedal_map_vaegir_lord_a"),
(else_try),
(eq, ":troop_faction_no", "fac_kingdom_3"),
(party_set_icon, "$pout_party", "icon_dedal_map_khergit_archer"),
(else_try),
(eq, ":troop_faction_no", "fac_kingdom_4"),
(party_set_icon, "$pout_party", "icon_dedal_map_nordic_lord_a"),
(else_try),
(eq, ":troop_faction_no", "fac_kingdom_5"),
(party_set_icon, "$pout_party", "icon_dedal_map_rhodok_lord_a"),
(else_try),
(eq, ":troop_faction_no", "fac_kingdom_6"),
(party_set_icon, "$pout_party", "icon_dedal_map_sarranid_lord_a"),
(try_end),

      (try_begin),
        #because of below two lines, lords can only hire more than one party_template(stack) at game start once a time during all game.
        (troop_slot_eq, ":troop_no", slot_troop_spawned_before, 0),
        (troop_set_slot, ":troop_no", slot_troop_spawned_before, 1),
        (assign, ":num_tries", 20),
        (try_begin),
          (store_troop_faction, ":troop_kingdom", ":troop_no"),
          (faction_slot_eq, ":troop_kingdom", slot_faction_leader, ":troop_no"),
          (assign, ":num_tries", 50),
        (try_end),

        #(str_store_troop_name, s0, ":troop_no"),
        #(display_message, "{!}str_debug__hiring_men_to_party_for_s0"),

        (try_for_range, ":unused", 0, ":num_tries"),
          (call_script, "script_hire_men_to_kingdom_hero_party", ":troop_no"),
        (try_end),

        (assign, ":mad:p_rounds", 0),

        (game_get_reduce_campaign_ai, ":reduce_campaign_ai"),
        (try_begin),
          (this_or_next|eq, ":troop_faction_no", "$players_kingdom"),
          (eq, ":troop_faction_no", "fac_player_supporters_faction"),
          (assign, ":mad:p_rounds", 0),
        (else_try),
          (eq, ":reduce_campaign_ai", 0), #hard
          (assign, ":mad:p_rounds", 2),
        (else_try),
          (eq, ":reduce_campaign_ai", 1), #moderate
          (assign, ":mad:p_rounds", 1),
        (else_try),
          (eq, ":reduce_campaign_ai", 2), #easy
          (assign, ":mad:p_rounds", 0),
        (try_end),

        (troop_get_slot, ":renown", ":troop_no", slot_troop_renown),
        (store_div, ":renown_xp_rounds", ":renown", 100),
        (val_add, ":mad:p_rounds", ":renown_xp_rounds"),
        (try_for_range, ":unused", 0, ":mad:p_rounds"),
          (call_script, "script_upgrade_hero_party", "$pout_party", 4000),
        (try_end),
      (try_end),
  ]),

Uses icons from here:
http://forums.taleworlds.com/index.php/topic,303947.0.html
 
Normally there's no way to automatically detect the game language, but since 1.161 has face code-related new operations including storing face codes as strings and facial features as integers, I think it can be done. Write a dummy string meant to correspond to a particular face code differently in the csv files for each language, then replace a dummy troop's face with it and store the hair value as a number. Once this version is out, I'll play with it.

/reserved
 
A script, which makes lords build upgrades in their settlements, if they can afford to.

It expands on the existing wealth pool for lords. If, after paying wages, the lord still has money left over, he will try to build an upgrade.
The script takes all centers which belong to the lord and are not currently building an upgrade, picks a random center from this pool and then builds a random available upgrade in that settlement.

Script expansion: Add the following to script_calculate_hero_weekly_net_income_and_add_to_wealth, and place right it above (val_max, ":cur_wealth", 0)
#### F&B begin make AI upgrade their settlements
Code:
    (try_begin),
        (ge, ":cur_wealth", 5000),
        (assign, ":upgrade_possible", 0),
        (call_script, "script_list_clear", "trp_upgrades"),
        (try_for_range, ":center_no", centers_begin, centers_end),
            (party_slot_eq, ":center_no", slot_town_lord, ":troop_no"),
            (party_slot_eq, ":center_no", slot_center_current_improvement, 0),
            (call_script, "script_list_add", "trp_upgrades", ":center_no"),
            (assign, ":upgrade_possible", 1),
        (try_end),
        (eq, ":upgrade_possible", 1),
        (call_script, "script_list_random", "trp_upgrades"),
        (assign, ":center_to_upgrade", reg1),
        (try_begin),
            (party_slot_eq, ":center_to_upgrade", slot_party_type, spt_village),
            (call_script, "script_list_clear", "trp_upgrades"),
            (assign, ":upgrade_available", 0),
            (try_for_range, ":upgrade", village_improvements_begin, village_improvements_end),
                (neg|party_slot_eq, ":center_to_upgrade", ":upgrade", 1),    #ignore already built upgrades
                (call_script, "script_list_add", "trp_upgrades", ":upgrade"),
                (assign, ":upgrade_available", 1),
            (try_end),
        (else_try),
            (party_slot_eq, ":center_to_upgrade", slot_party_type, spt_castle),
            (call_script, "script_list_clear", "trp_upgrades"),
            (assign, ":upgrade_available", 0),
            (try_for_range, ":upgrade", walled_center_improvements_begin, walled_center_improvements_end),
                (neg|party_slot_eq, ":center_to_upgrade", ":upgrade", 1),
                (call_script, "script_list_add", "trp_upgrades", ":upgrade"),
                (assign, ":upgrade_available", 1),
            (try_end),
        (else_try),
            (party_slot_eq, ":center_to_upgrade", slot_party_type, spt_town),
            (call_script, "script_list_clear", "trp_upgrades"),
            (assign, ":upgrade_available", 0),
            (try_for_range, ":upgrade", walled_center_improvements_begin, walled_center_improvements_end),
                (neg|party_slot_eq, ":center_to_upgrade", ":upgrade", 1),
                (call_script, "script_list_add", "trp_upgrades", ":upgrade"),
                (assign, ":upgrade_available", 1),
            (try_end),          
        (try_end),              
        (eq, ":upgrade_available", 1),
        (call_script, "script_list_random", "trp_upgrades"),
        (assign, ":new_upgrade", reg1),
        (call_script, "script_get_improvement_details", reg1),
        (assign, ":improvement_cost", reg0),
        (store_div, ":improvement_time", ":improvement_cost", 150),
        (party_set_slot, ":center_to_upgrade", slot_center_current_improvement, ":new_upgrade"),
        (store_current_hours, ":cur_hours"),
        (store_mul, ":hours_takes", ":improvement_time", 24),
        (val_add, ":hours_takes", ":cur_hours"),
        (party_set_slot, ":center_to_upgrade", slot_center_improvement_end_hour, ":hours_takes"),
        (val_sub, ":cur_wealth", ":improvement_cost"),
        (str_store_party_name, s0, ":center_to_upgrade"),
#        (display_message, "@ {s0} is building an upgrade. Final wealth: {reg7}"),
    (try_end),
#### F&B end make AI upgrade their settlements
##############################################################################
Code:
      (val_sub, ":weekly_income", ":cur_weekly_wage"),
    
      (val_add, ":cur_wealth", ":weekly_income"),
    
      (try_begin),
        (lt, ":cur_wealth", 0),
        (store_sub, ":percent_under", 0, ":cur_wealth"),
        (val_mul, ":percent_under", 100),
        (val_div, ":percent_under", ":cur_weekly_wage"),
        (val_div, ":percent_under", 5), #Max 20 percent
      
        (call_script, "script_party_inflict_attrition", ":party_no", ":percent_under", 1),
      (try_end),
#### F&B begin make AI upgrade their settlements      
    (try_begin),
        (ge, ":cur_wealth", 5000),
        (assign, ":upgrade_possible", 0),
        (call_script, "script_list_clear", "trp_upgrades"),
        (try_for_range, ":center_no", centers_begin, centers_end),
            (party_slot_eq, ":center_no", slot_town_lord, ":party_no"),
            (party_slot_eq, ":center_no", slot_center_current_improvement, 0),
            (call_script, "script_list_add", "trp_upgrades", ":center_no"),
            (assign, ":upgrade_possible", 1),
        (try_end),
        (eq, ":upgrade_possible", 1),
        (call_script, "script_list_random", "trp_upgrades"),
        (assign, ":center_to_upgrade", reg1),
        (try_begin),
            (party_slot_eq, ":center_to_upgrade", slot_party_type, spt_village),
            (call_script, "script_list_clear", "trp_upgrades"),
            (assign, ":upgrade_available", 0),
            (try_for_range, ":upgrade", village_improvements_begin, village_improvements_end),
                (neg|party_slot_eq, ":center_to_upgrade", ":upgrade", 1),    #ignore already built upgrades
                (call_script, "script_list_add", "trp_upgrades", ":upgrade"),
                (assign, ":upgrade_available", 1),
            (try_end),
        (else_try),
            (party_slot_eq, ":center_to_upgrade", slot_party_type, spt_castle),
            (call_script, "script_list_clear", "trp_upgrades"),
            (assign, ":upgrade_available", 0),
            (try_for_range, ":upgrade", walled_center_improvements_begin, walled_center_improvements_end),
                (neg|party_slot_eq, ":center_to_upgrade", ":upgrade", 1),
                (call_script, "script_list_add", "trp_upgrades", ":upgrade"),
                (assign, ":upgrade_available", 1),
            (try_end),
        (else_try),
            (party_slot_eq, ":center_to_upgrade", slot_party_type, spt_town),
            (call_script, "script_list_clear", "trp_upgrades"),
            (assign, ":upgrade_available", 0),
            (try_for_range, ":upgrade", walled_center_improvements_begin, walled_center_improvements_end),
                (neg|party_slot_eq, ":center_to_upgrade", ":upgrade", 1),
                (call_script, "script_list_add", "trp_upgrades", ":upgrade"),
                (assign, ":upgrade_available", 1),
            (try_end),          
        (try_end),              
        (eq, ":upgrade_available", 1),
        (call_script, "script_list_random", "trp_upgrades"),
        (assign, ":new_upgrade", reg1),
        (call_script, "script_get_improvement_details", reg1),
        (assign, ":improvement_cost", reg0),
        (store_div, ":improvement_time", ":improvement_cost", 150),
        (party_set_slot, ":center_to_upgrade", slot_center_current_improvement, ":new_upgrade"),
        (store_current_hours, ":cur_hours"),
        (store_mul, ":hours_takes", ":improvement_time", 24),
        (val_add, ":hours_takes", ":cur_hours"),
        (party_set_slot, ":center_to_upgrade", slot_center_improvement_end_hour, ":hours_takes"),
        (val_sub, ":cur_wealth", ":improvement_cost"),
        (str_store_party_name, s0, ":center_to_upgrade"),
#        (display_message, "@ {s0} is building an upgrade. Final wealth: {reg7}"),
    (try_end),
#### F&B end make AI upgrade their settlements
##############################################################################
      (val_max, ":cur_wealth", 0),
      (troop_set_slot, ":troop_no", slot_troop_wealth, ":cur_wealth"),
  ]),

You'll also need a few scripts from Lumos list system. Place them anywhere in module_scripts:
Code:
#-## List management
## The list's zero slot holds the number of current items in it
# script_list_random
# Returns a random element from the list, along with its index
# INPUT: none
# OUTPUT: reg1 - the value of the item, reg2 - its index
("list_random", [
    (store_script_param, ":list_type", 1),
    (troop_get_slot, ":num_elements", ":list_type", 0),
    (val_add, ":num_elements", 1),
    (store_random_in_range, reg2, 1, ":num_elements"),
    (troop_get_slot, reg1, ":list_type", reg2),
]),
# script_list_add
# Appends an item to the list
# INPUT: arg1 - the value which we will add to the list
# OUTPUT: none
("list_add", [
    (store_script_param, ":list_type", 1),
    (store_script_param, ":value", 2),
    (troop_get_slot, ":num_elements", ":list_type", 0),
    (val_add, ":num_elements", 1),
    (troop_set_slot, ":list_type", ":num_elements", ":value"),
    (troop_set_slot, ":list_type", 0, ":num_elements"),
]),
# script_list_clear
# Clears all items from the list
# INPUT: ":list_type"
# OUTPUT: none
("list_clear", [
    (store_script_param, ":list_type", 1),
    (troop_get_slot, ":num_elements", ":list_type", 0),
    (val_add, ":num_elements", 1),
    (try_for_range, ":slot", 1, ":num_elements"),
        (troop_set_slot, ":list_type", ":slot", 0),
    (try_end),
    (troop_set_slot, ":list_type", 0, 0), # Reset number of elements
]),

Finally, the troop, which temporarily holds the lists. Place it near the bottom, but before the final "]":
Code:
  ["upgrades", "{!}Upgrade list", "{!}List of available upgrades", tf_hero, no_scene, reserved, fac_neutral,[],level(60),wp(800),knight_skills_5,merchant_face_1, merchant_face_2],
 
Last edited by a moderator:
Fire_and_Blood said:
A script, which makes lords build upgrades in their settlements, if they can afford to.

It expands on the existing wealth pool for lords. If, after paying wages, the lord still has money left over, he will try to build an upgrade.
The script takes all centers which belong to the lord and are not currently building an upgrade, picks a random center from this pool and then builds a random available upgrade in that settlement.

Script expansion: Add the following to script_calculate_hero_weekly_net_income_and_add_to_wealth, and place right it above (val_max, ":cur_wealth", 0)
#### F&B begin make AI upgrade their settlements
(try_begin),
(ge, ":cur_wealth", 5000),
(assign, ":upgrade_possible", 0),
(call_script, "script_list_clear", "trp_upgrades"),
(try_for_range, ":center_no", centers_begin, centers_end),
(party_slot_eq, ":center_no", slot_town_lord, ":party_no"),
(party_slot_eq, ":center_no", slot_center_current_improvement, 0),
(call_script, "script_list_add", "trp_upgrades", ":center_no"),
(assign, ":upgrade_possible", 1),
(try_end),
(eq, ":upgrade_possible", 1),
(call_script, "script_list_random", "trp_upgrades"),
(assign, ":center_to_upgrade", reg1),
(try_begin),
(party_slot_eq, ":center_to_upgrade", slot_party_type, spt_village),
(call_script, "script_list_clear", "trp_upgrades"),
(assign, ":upgrade_available", 0),
(try_for_range, ":upgrade", village_improvements_begin, village_improvements_end),
(neg|party_slot_eq, ":center_to_upgrade", ":upgrade", 1), #ignore already built upgrades
(call_script, "script_list_add", "trp_upgrades", ":upgrade"),
(assign, ":upgrade_available", 1),
(try_end),
(else_try),
(party_slot_eq, ":center_to_upgrade", slot_party_type, spt_castle),
(call_script, "script_list_clear", "trp_upgrades"),
(assign, ":upgrade_available", 0),
(try_for_range, ":upgrade", walled_center_improvements_begin, walled_center_improvements_end),
(neg|party_slot_eq, ":center_to_upgrade", ":upgrade", 1),
(call_script, "script_list_add", "trp_upgrades", ":upgrade"),
(assign, ":upgrade_available", 1),
(try_end),
(else_try),
(party_slot_eq, ":center_to_upgrade", slot_party_type, spt_town),
(call_script, "script_list_clear", "trp_upgrades"),
(assign, ":upgrade_available", 0),
(try_for_range, ":upgrade", walled_center_improvements_begin, walled_center_improvements_end),
(neg|party_slot_eq, ":center_to_upgrade", ":upgrade", 1),
(call_script, "script_list_add", "trp_upgrades", ":upgrade"),
(assign, ":upgrade_available", 1),
(try_end),
(try_end),
(eq, ":upgrade_available", 1),
(call_script, "script_list_random", "trp_upgrades"),
(assign, ":new_upgrade", reg1),
(call_script, "script_get_improvement_details", reg1),
(assign, ":improvement_cost", reg0),
(store_div, ":improvement_time", ":improvement_cost", 150),
(party_set_slot, ":center_to_upgrade", slot_center_current_improvement, ":new_upgrade"),
(store_current_hours, ":cur_hours"),
(store_mul, ":hours_takes", ":improvement_time", 24),
(val_add, ":hours_takes", ":cur_hours"),
(party_set_slot, ":center_to_upgrade", slot_center_improvement_end_hour, ":hours_takes"),
(val_sub, ":cur_wealth", ":improvement_cost"),
(str_store_party_name, s0, ":center_to_upgrade"),
# (display_message, "@ {s0} is building an upgrade. Final wealth: {reg7}"),
(try_end),
#### F&B end make AI upgrade their settlements
##############################################################################
      (val_sub, ":weekly_income", ":cur_weekly_wage"),
     
      (val_add, ":cur_wealth", ":weekly_income"),
     
      (try_begin),
        (lt, ":cur_wealth", 0),
        (store_sub, ":percent_under", 0, ":cur_wealth"),
        (val_mul, ":percent_under", 100),
        (val_div, ":percent_under", ":cur_weekly_wage"),
        (val_div, ":percent_under", 5), #Max 20 percent
       
        (call_script, "script_party_inflict_attrition", ":party_no", ":percent_under", 1),
      (try_end),
#### F&B begin make AI upgrade their settlements
(try_begin),
(ge, ":cur_wealth", 5000),
(assign, ":upgrade_possible", 0),
(call_script, "script_list_clear", "trp_upgrades"),
(try_for_range, ":center_no", centers_begin, centers_end),
(party_slot_eq, ":center_no", slot_town_lord, ":party_no"),
(party_slot_eq, ":center_no", slot_center_current_improvement, 0),
(call_script, "script_list_add", "trp_upgrades", ":center_no"),
(assign, ":upgrade_possible", 1),
(try_end),
(eq, ":upgrade_possible", 1),
(call_script, "script_list_random", "trp_upgrades"),
(assign, ":center_to_upgrade", reg1),
(try_begin),
(party_slot_eq, ":center_to_upgrade", slot_party_type, spt_village),
(call_script, "script_list_clear", "trp_upgrades"),
(assign, ":upgrade_available", 0),
(try_for_range, ":upgrade", village_improvements_begin, village_improvements_end),
(neg|party_slot_eq, ":center_to_upgrade", ":upgrade", 1), #ignore already built upgrades
(call_script, "script_list_add", "trp_upgrades", ":upgrade"),
(assign, ":upgrade_available", 1),
(try_end),
(else_try),
(party_slot_eq, ":center_to_upgrade", slot_party_type, spt_castle),
(call_script, "script_list_clear", "trp_upgrades"),
(assign, ":upgrade_available", 0),
(try_for_range, ":upgrade", walled_center_improvements_begin, walled_center_improvements_end),
(neg|party_slot_eq, ":center_to_upgrade", ":upgrade", 1),
(call_script, "script_list_add", "trp_upgrades", ":upgrade"),
(assign, ":upgrade_available", 1),
(try_end),
(else_try),
(party_slot_eq, ":center_to_upgrade", slot_party_type, spt_town),
(call_script, "script_list_clear", "trp_upgrades"),
(assign, ":upgrade_available", 0),
(try_for_range, ":upgrade", walled_center_improvements_begin, walled_center_improvements_end),
(neg|party_slot_eq, ":center_to_upgrade", ":upgrade", 1),
(call_script, "script_list_add", "trp_upgrades", ":upgrade"),
(assign, ":upgrade_available", 1),
(try_end),
(try_end),
(eq, ":upgrade_available", 1),
(call_script, "script_list_random", "trp_upgrades"),
(assign, ":new_upgrade", reg1),
(call_script, "script_get_improvement_details", reg1),
(assign, ":improvement_cost", reg0),
(store_div, ":improvement_time", ":improvement_cost", 150),
(party_set_slot, ":center_to_upgrade", slot_center_current_improvement, ":new_upgrade"),
(store_current_hours, ":cur_hours"),
(store_mul, ":hours_takes", ":improvement_time", 24),
(val_add, ":hours_takes", ":cur_hours"),
(party_set_slot, ":center_to_upgrade", slot_center_improvement_end_hour, ":hours_takes"),
(val_sub, ":cur_wealth", ":improvement_cost"),
(str_store_party_name, s0, ":center_to_upgrade"),
# (display_message, "@ {s0} is building an upgrade. Final wealth: {reg7}"),
(try_end),
#### F&B end make AI upgrade their settlements
##############################################################################
      (val_max, ":cur_wealth", 0),
      (troop_set_slot, ":troop_no", slot_troop_wealth, ":cur_wealth"),
  ]),

You'll also need a few scripts from Lumos list system. Place them anywhere in module_scripts:
#-## List management
## The list's zero slot holds the number of current items in it
# script_list_random
# Returns a random element from the list, along with its index
# INPUT: none
# OUTPUT: reg1 - the value of the item, reg2 - its index
("list_random", [
(store_script_param, ":list_type", 1),
(troop_get_slot, ":num_elements", ":list_type", 0),
(val_add, ":num_elements", 1),
(store_random_in_range, reg2, 1, ":num_elements"),
(troop_get_slot, reg1, ":list_type", reg2),
]),
# script_list_add
# Appends an item to the list
# INPUT: arg1 - the value which we will add to the list
# OUTPUT: none
("list_add", [
(store_script_param, ":list_type", 1),
(store_script_param, ":value", 2),
(troop_get_slot, ":num_elements", ":list_type", 0),
(val_add, ":num_elements", 1),
(troop_set_slot, ":list_type", ":num_elements", ":value"),
(troop_set_slot, ":list_type", 0, ":num_elements"),
]),
# script_list_clear
# Clears all items from the list
# INPUT: ":list_type"
# OUTPUT: none
("list_clear", [
(store_script_param, ":list_type", 1),
(troop_get_slot, ":num_elements", ":list_type", 0),
(val_add, ":num_elements", 1),
(try_for_range, ":slot", 1, ":num_elements"),
(troop_set_slot, ":list_type", ":slot", 0),
(try_end),
(troop_set_slot, ":list_type", 0, 0), # Reset number of elements
]),

Finally, the troop, which temporarily holds the lists. Place it near the bottom, but before the final "]":
  ["upgrades", "{!}Upgrade list", "{!}List of available upgrades", tf_hero, no_scene, reserved, fac_neutral,[],level(60),wp(800),knight_skills_5,merchant_face_1, merchant_face_2], 

Thanks <3 I really enjoy this script :grin:
 
Belendor the Crazy Cheese said:
dunde said:
enhanced script_initialize_aristocracy of WB 1.143 Native :
- Kings have 1 or 2 sons and daughters.
- Adjust Kings' and lord's Face code according to their age.
- Giving variety of lady's age. (They 're no longer always be 19, 21, or 49 years old anymore)

Code:
    ("initialize_aristocracy",
    [
      #LORD OCCUPATIONS, BLOOD RELATIONSHIPS, RENOWN AND REPUTATIONS
      
      #King ages
      (try_for_range, ":cur_troop", kings_begin, kings_end),
        (troop_set_slot, ":cur_troop", slot_troop_occupation, slto_kingdom_hero),
        (store_random_in_range, ":age", 50, 60),
        (try_begin),
              (eq, ":cur_troop", "trp_kingdom_5_lord"),
           (assign, ":age", 47),
        (try_end),   
        (call_script, "script_init_troop_age", ":cur_troop", ":age"),
      (try_end),
            
      #The first thing - family structure
      #lords 1 to 8 are patriarchs with one live-at-home son and one daughter. They come from one of six possible ancestors, thus making it likely that there will be two sets of siblings
      #lords 9 to 12 are unmarried landowners with sisters
      #lords 13 to 20 are sons who still live in their fathers' houses
      #For the sake of simplicity, we can assume that all male aristocrats in prior generations either married commoners or procured their brides from the Old Country, thus discounting intermarriage 

      (try_for_range, ":cur_troop", kingdom_ladies_begin, kingdom_ladies_end),
        (troop_set_slot, ":cur_troop", slot_troop_occupation, slto_kingdom_lady),
      (try_end),
      
      (assign, ":cur_lady", "trp_kingdom_1_lady_1"),

      (try_for_range, ":cur_troop", lords_begin, lords_end),  
        (troop_set_slot, ":cur_troop", slot_troop_occupation, slto_kingdom_hero),
        
        (store_random_in_range, ":father_age_at_birth", 23, 26),
#        (store_random_in_range, ":mother_age_at_birth", 19, 22),
        
        (try_begin),
            (is_between, ":cur_troop", "trp_knight_1_1", "trp_knight_2_1"),
            (store_sub, ":npc_seed", ":cur_troop", "trp_knight_1_1"),
            (assign, ":ancestor_seed", 1),
            (assign, ":king", "trp_kingdom_1_lord"),
        (else_try),
            (is_between, ":cur_troop", "trp_knight_2_1", "trp_knight_3_1"),
            (store_sub, ":npc_seed", ":cur_troop", "trp_knight_2_1"),
            (assign, ":ancestor_seed", 7),
            (assign, ":king", "trp_kingdom_2_lord"),
        (else_try),
            (is_between, ":cur_troop", "trp_knight_3_1", "trp_knight_4_1"),
            (store_sub, ":npc_seed", ":cur_troop", "trp_knight_3_1"),
            (assign, ":ancestor_seed", 13),
            (assign, ":king", "trp_kingdom_3_lord"),
        (else_try),
            (is_between, ":cur_troop", "trp_knight_4_1", "trp_knight_5_1"),
            (store_sub, ":npc_seed", ":cur_troop", "trp_knight_4_1"),
            (assign, ":ancestor_seed", 19),
            (assign, ":king", "trp_kingdom_4_lord"),
        (else_try),
            (is_between, ":cur_troop", "trp_knight_5_1", "trp_knight_6_1"),
            (store_sub, ":npc_seed", ":cur_troop", "trp_knight_5_1"),
            (assign, ":ancestor_seed", 25),
            (assign, ":king", "trp_kingdom_5_lord"),
        (else_try),
            (is_between, ":cur_troop", "trp_knight_6_1", "trp_kingdom_1_pretender"),
            (store_sub, ":npc_seed", ":cur_troop", "trp_knight_6_1"),
            (assign, ":ancestor_seed", 31),
            (assign, ":king", "trp_kingdom_6_lord"),
        (try_end),
        
        
        (try_begin), #NPC seed is the order in the faction
            (lt, ":npc_seed", 8), #Senior lords
            (assign, ":reputation", ":npc_seed"),
            (store_random_in_range, ":age", 45, 64),
            
            (store_random_in_range, ":father", 0, 6), #six possible fathers
            (val_add, ":father", ":ancestor_seed"),
            (troop_set_slot, ":cur_troop", slot_troop_father, ":father"), # Father is not active npc
            
            #wife
            (troop_set_slot, ":cur_troop", slot_troop_spouse, ":cur_lady"),
            (troop_set_slot, ":cur_lady", slot_troop_spouse, ":cur_troop"),
            (store_random_in_range, ":wife_reputation", 20, 26),
            (try_begin),
                (eq, ":wife_reputation", 20),
                (assign, ":wife_reputation", lrep_conventional),
            (try_end),
            (troop_set_slot, ":cur_lady", slot_lord_reputation_type, ":wife_reputation"),
            
            (store_random_in_range, ":lady_age", 40, ":age"),
            (call_script, "script_init_troop_age", ":cur_lady", ":lady_age"),
            (call_script, "script_add_lady_items", ":cur_lady"),
            
            (val_add, ":cur_lady", 1),

            #daughter
            (troop_set_slot, ":cur_lady", slot_troop_father, ":cur_troop"),
            (store_sub, ":mother", ":cur_lady", 1),
            (store_random_in_range, ":lady_age", 17, 25),
            (val_max, ":lady_age", 19),
            (call_script, "script_init_troop_age", ":cur_lady", ":lady_age"),
            (troop_set_slot, ":cur_lady", slot_troop_mother, ":cur_lady"),
            (store_random_in_range, ":lady_reputation", lrep_conventional, 34), #33% chance of father-derived
            (try_begin),
                (le, ":lady_reputation", 25),
                (troop_set_slot, ":cur_lady", slot_lord_reputation_type, ":lady_reputation"),
            (else_try),    
                (eq, ":lady_reputation", 26),
                (troop_set_slot, ":cur_lady", slot_lord_reputation_type, lrep_conventional),
            (else_try),    
                (eq, ":lady_reputation", 27),
                (troop_set_slot, ":cur_lady", slot_lord_reputation_type, lrep_moralist),
            (else_try),
                (assign, ":guardian_reputation", ":reputation"),
                (try_begin),
                    (this_or_next|eq, ":guardian_reputation", lrep_martial),
                        (eq, ":guardian_reputation", 0),
                    (troop_set_slot, ":cur_lady", slot_lord_reputation_type, lrep_conventional),
                (else_try),        
                    (eq, ":guardian_reputation", lrep_quarrelsome),
                    (troop_set_slot, ":cur_lady", slot_lord_reputation_type, lrep_otherworldly),
                (else_try),        
                    (eq, ":guardian_reputation", lrep_selfrighteous),
                    (troop_set_slot, ":cur_lady", slot_lord_reputation_type, lrep_ambitious),
                (else_try),        
                    (eq, ":guardian_reputation", lrep_cunning),
                    (troop_set_slot, ":cur_lady", slot_lord_reputation_type, lrep_adventurous),
                (else_try),        
                    (eq, ":guardian_reputation", lrep_goodnatured),
                    (troop_set_slot, ":cur_lady", slot_lord_reputation_type, lrep_adventurous),
                (else_try),        
                    (eq, ":guardian_reputation", lrep_debauched),
                    (troop_set_slot, ":cur_lady", slot_lord_reputation_type, lrep_ambitious),
                (else_try),        
                    (eq, ":guardian_reputation", lrep_upstanding),
                    (troop_set_slot, ":cur_lady", slot_lord_reputation_type, lrep_moralist),
                (try_end),
            (try_end),
            
            (call_script, "script_add_lady_items", ":cur_lady"),
            (val_add, ":cur_lady", 1),
            #high renown

        (else_try),    #Older unmarried lords
            (is_between, ":npc_seed", 8, 12), # Dunde gives sons to the kings
            (store_random_in_range, ":age", 25, 36),            
            (store_random_in_range, ":reputation", 0, 8),    
            (try_begin),
               (is_between, ":npc_seed", 8, 10),
               (this_or_next|eq, ":npc_seed", 8), (ge, ":reputation", 6),
               (troop_set_slot, ":cur_troop", slot_troop_father, ":king"),
               (val_min, ":age", 28), # we want young princes
            (try_end),        
            (try_begin),
                # No Father
                (troop_slot_lt, ":cur_troop", slot_troop_father, 0), 
                (store_random_in_range, ":sister_reputation", 20, 26),
                (try_begin),
                    (eq, ":sister_reputation", 20),
                    (assign, ":sister_reputation", lrep_conventional),
                (try_end),
                (troop_set_slot, ":cur_lady", slot_lord_reputation_type, ":sister_reputation"),            
                (troop_set_slot, ":cur_lady", slot_troop_guardian, ":cur_troop"),
            (else_try),
                # King's son
                (try_begin), #50% chance of having father's rep
                   (store_random_in_range, ":reputation", 0, 16),
                   (gt, ":reputation", 7),
                   (troop_get_slot, ":reputation", ":king", slot_lord_reputation_type),
                (try_end),
                (troop_set_slot, ":cur_lady", slot_troop_father, ":king"),
                (store_random_in_range, ":lady_reputation", lrep_conventional, 34), #33% chance of father-derived
                (try_begin),
                    (le, ":lady_reputation", 25),
                    (troop_set_slot, ":cur_lady", slot_lord_reputation_type, ":lady_reputation"),
                (else_try),    
                    (eq, ":lady_reputation", 26),
                    (troop_set_slot, ":cur_lady", slot_lord_reputation_type, lrep_conventional),
                (else_try),    
                    (eq, ":lady_reputation", 27),
                    (troop_set_slot, ":cur_lady", slot_lord_reputation_type, lrep_moralist),
                (else_try),
                    (assign, ":guardian_reputation", ":reputation"),
                    (try_begin),
                        (this_or_next|eq, ":guardian_reputation", lrep_martial),
                            (eq, ":guardian_reputation", 0),
                        (troop_set_slot, ":cur_lady", slot_lord_reputation_type, lrep_conventional),
                    (else_try),        
                        (eq, ":guardian_reputation", lrep_quarrelsome),
                        (troop_set_slot, ":cur_lady", slot_lord_reputation_type, lrep_otherworldly),
                    (else_try),        
                        (eq, ":guardian_reputation", lrep_selfrighteous),
                        (troop_set_slot, ":cur_lady", slot_lord_reputation_type, lrep_ambitious),
                    (else_try),        
                        (eq, ":guardian_reputation", lrep_cunning),
                        (troop_set_slot, ":cur_lady", slot_lord_reputation_type, lrep_adventurous),
                    (else_try),        
                        (eq, ":guardian_reputation", lrep_goodnatured),
                        (troop_set_slot, ":cur_lady", slot_lord_reputation_type, lrep_adventurous),
                    (else_try),        
                        (eq, ":guardian_reputation", lrep_debauched),
                        (troop_set_slot, ":cur_lady", slot_lord_reputation_type, lrep_ambitious),
                    (else_try),        
                        (eq, ":guardian_reputation", lrep_upstanding),
                        (troop_set_slot, ":cur_lady", slot_lord_reputation_type, lrep_moralist),
                    (try_end),
                (try_end),           
            (try_end),
            (store_random_in_range, ":lady_age", 15, 28),
            (val_max, ":lady_age", 21),
            (call_script, "script_init_troop_age", ":cur_lady", ":lady_age"),
            (call_script, "script_add_lady_items", ":cur_lady"),
            
            (val_add, ":cur_lady", 1),
            
        (else_try),    #Younger unmarried lords 
            #age is father's minus 20 to 25
            (store_sub, ":father", ":cur_troop", 12),
            (troop_set_slot, ":cur_troop", slot_troop_father, ":father"),
            (troop_get_slot, ":mother", ":father", slot_troop_spouse),
            (troop_set_slot, ":cur_troop", slot_troop_mother, ":mother"),
            
            (troop_get_slot, ":father_age", ":father", slot_troop_age),
            (store_sub, ":age", ":father_age", ":father_age_at_birth"),

            (try_begin), #50% chance of having father's rep
                (store_random_in_range, ":reputation", 0, 16),

                (gt, ":reputation", 7),
                (troop_get_slot, ":reputation", ":father", slot_lord_reputation_type),
            (try_end),
        (try_end),
        
        (try_begin),
            (eq, ":reputation", 0),
            (assign, ":reputation", 1),
        (try_end),
        
        (troop_set_slot, ":cur_troop", slot_lord_reputation_type, ":reputation"),

        (call_script, "script_init_troop_age", ":cur_troop", ":age"),
      (try_end),
      
      (try_begin),
        (eq, "$cheat_mode", 1),
        (assign, reg3, "$cheat_mode"),
        (display_message, "@{!}DEBUG -- Assigned lord reputation and relations"),
        
#        (display_message, "str_assigned_lord_reputation_and_relations_cheat_mode_reg3"), #This string can be removed
      (try_end),
      
      (try_for_range, ":cur_troop", pretenders_begin, pretenders_end),
        (troop_set_slot, ":cur_troop", slot_troop_occupation, slto_inactive_pretender),
        (store_random_in_range, ":age", 25, 30),
        #(troop_set_slot, ":cur_troop", slot_troop_age, ":age"),
        (try_begin),
           (eq, ":cur_troop", "trp_kingdom_5_pretender"),
           (assign, ":age", 45),
        (try_end),   
        (call_script, "script_init_troop_age", ":cur_troop", ":age"),
      (try_end),
    ]),

mb1-1.jpg

Usable. But, being a son of Monarch should have benefits for good.

Interesting... Seeing that Lords and Kings have B-Days, I will probably use this and add dialogue for wishing them happy birthday. it could be an easy way to gain relation with lords  :lol:
 
I got a concept of a script here to send multiple true-false values trought a single multiplayer_send_int_to_player/server operation.
I guess there are many places this is already used but I've never seen anyone doing it in WB so here it is:

Code:
		(try_for_range, ":scn", 1, "scn_enterprise_oil_press"),
			## using a single multiplayer_send_4_int_to_player to send a lot of true-false options to speed up the process
			#":val" will have a number ranging from 0 to 511 depending on which values are true
			(scene_get_slot, ":val", ":scn", slot_scene_lwbr_available_dm),
			(scene_get_slot, ":value", ":scn", slot_scene_lwbr_available_tdm),
			(val_mul, ":value", 2),
			(val_add, ":val", ":value"),
			(scene_get_slot, ":value", ":scn", slot_scene_lwbr_available_hq),
			(val_mul, ":value", 4),
			(val_add, ":val", ":value"),
			(scene_get_slot, ":value", ":scn", slot_scene_lwbr_available_cf),
			(val_mul, ":value", 8),
			(val_add, ":val", ":value"),
			(scene_get_slot, ":value", ":scn", slot_scene_lwbr_available_sg),
			(val_mul, ":value", 16),
			(val_add, ":val", ":value"),
			(scene_get_slot, ":value", ":scn", slot_scene_lwbr_available_bt),
			(val_mul, ":value", 32),
			(val_add, ":val", ":value"),
			(scene_get_slot, ":value", ":scn", slot_scene_lwbr_available_bt),
			(val_mul, ":value", 64),
			(val_add, ":val", ":value"),
			(scene_get_slot, ":value", ":scn", slot_scene_lwbr_available_duel),
			(val_mul, ":value", 128),
			(val_add, ":val", ":value"),
			(scene_get_slot, ":value", ":scn", slot_scene_lwbr_available_rotation),
			(val_mul, ":value", 256),
			(val_add, ":val", ":value"),
			(multiplayer_send_4_int_to_player, ":player_no", multiplayer_event_lwbr_client, lwbr_client_set_scene_slot, ":scn", slot_scene_lwbr_combo, ":val"),
		(try_end),
you can see why I used it in this case, I'd be sending 9 msgs for each scene and I'm iterating trought all scenes in module_scenes, so that'd get a little messy(it took about 5 seconds to send from my local hosted server to my own client)

and:
Code:
					(eq,":type",lwbr_client_set_scene_slot),
					(try_begin),
						(is_between, ":var", 0, num_of_scenes),
						(eq, ":value", slot_scene_lwbr_combo),
						## using a single multiplayer_send_4_int_to_player to send a lot of true-false options to speed up the process
						#":value2" will have a number ranging from 0 to 511 depending on which values are true
						(try_begin),
							(ge, ":value2", 256),
							(scene_set_slot, ":var", slot_scene_lwbr_available_rotation, 1),
						(else_try),
							(scene_set_slot, ":var", slot_scene_lwbr_available_rotation, 0),
						(try_end),
						(try_begin),
							(ge, ":value2", 128),
							(scene_set_slot, ":var", slot_scene_lwbr_available_duel, 1),
						(else_try),
							(scene_set_slot, ":var", slot_scene_lwbr_available_duel, 0),
						(try_end),
						(try_begin),
							(ge, ":value2", 64),
							(scene_set_slot, ":var", slot_scene_lwbr_available_fd, 1),
						(else_try),
							(scene_set_slot, ":var", slot_scene_lwbr_available_fd, 0),
						(try_end),
						(try_begin),
							(ge, ":value2", 32),
							(scene_set_slot, ":var", slot_scene_lwbr_available_bt, 1),
						(else_try),
							(scene_set_slot, ":var", slot_scene_lwbr_available_bt, 0),
						(try_end),
						(try_begin),
							(ge, ":value2", 16),
							(scene_set_slot, ":var", slot_scene_lwbr_available_sg, 1),
						(else_try),
							(scene_set_slot, ":var", slot_scene_lwbr_available_sg, 0),
						(try_end),
						(try_begin),
							(ge, ":value2", 8),
							(scene_set_slot, ":var", slot_scene_lwbr_available_cf, 1),
						(else_try),
							(scene_set_slot, ":var", slot_scene_lwbr_available_cf, 0),
						(try_end),
						(try_begin),
							(ge, ":value2", 4),
							(scene_set_slot, ":var", slot_scene_lwbr_available_hq, 1),
						(else_try),
							(scene_set_slot, ":var", slot_scene_lwbr_available_hq, 0),
						(try_end),
						(try_begin),
							(ge, ":value2", 2),
							(scene_set_slot, ":var", slot_scene_lwbr_available_tdm, 1),
						(else_try),
							(scene_set_slot, ":var", slot_scene_lwbr_available_tdm, 0),
						(try_end),
						(try_begin),
							(ge, ":value2", 1),
							(scene_set_slot, ":var", slot_scene_lwbr_available_dm, 1),
						(else_try),
							(scene_set_slot, ":var", slot_scene_lwbr_available_dm, 0),
						(try_end),
						##
					(else_try),
						(is_between, ":var", 0, num_of_scenes),
						(scene_set_slot, ":var", ":value", ":value2"),
					(else_try),
						(display_message, "@Invalid scene no from 'lwbr_client_set_scene_slot'"),
					(try_end),

this code is not optimized at all(as in, this could have been written which much less lines) but as I don't pretend to use it anywhere else for now I'll leave it as is  :lol:
 
I wrote this small python script for Perisno. It will output a list of item names that are not being used by any troops.

save it as unused_items.py and place it in the same directory as all of your ID, Header, and Module python files.

Code:
from module_troops import troops

item_set = []
troop_items = []
unused_items = []

print ("Grabbing item names and values from ID_items.py")
item_IDs = open("ID_items.py", "r")

for i, line in enumerate(item_IDs):
  numberPos = line.find('=') + 2
  namePos = numberPos - 3
  name = line[4:namePos]
  number = line[numberPos:-1]
  item_set.append([name, int(number)])

print (str(len(item_set)) + " items found")

print ("Grabbing item values from module_troops.py")
for i, v in enumerate(troops):
  for j, b in enumerate(v[7]):
    if (troop_items.count(b) == 0):
      troop_items.append(b)
      
print (str(len(troop_items)) + " items used by troops")

item_used = False

for i, v in enumerate(item_set):
  item_used = False
  for j, b in enumerate(troop_items):
    if (b == v[1]):
      item_used = True
  
  if (not item_used):
    unused_items.append(v[0])
        
print (str(len(unused_items)) + " unused item names saved to unused_items.txt")

file = open("unused_items.txt", "w")

for i, v in enumerate(unused_items):
  file.write(unused_items[i] + '\n')

file.close()

print ("Finished")
 
Zephilinox said:
save it as unused_items.py and place it in the same directory as all of your ID, Header, and Module python files.

Done that, but nothing happens after compile or running it with python... i'm not into python, so could you tell me what i'm missing out? :smile:
 
keinPlan86m said:
Zephilinox said:
save it as unused_items.py and place it in the same directory as all of your ID, Header, and Module python files.

Done that, but nothing happens after compile or running it with python... i'm not into python, so could you tell me what i'm missing out? :smile:

edit your build_module.bat file so that it has this line somewhere

Code:
python unused_items.py

so that it looks something like this

@echo off
python process_init.py
python process_global_variables.py
python process_strings.py
python process_skills.py
python process_music.py
python process_animations.py
python process_meshes.py
python process_sounds.py
python process_skins.py
python process_map_icons.py
python process_factions.py
python process_items.py
python process_scenes.py
python process_troops.py
python process_particle_sys.py
python process_scene_props.py
python process_tableau_materials.py
python process_presentations.py
python process_party_tmps.py
python process_parties.py
python process_quests.py
python process_info_pages.py
python process_scripts.py
python process_mission_tmps.py
python process_game_menus.py
python process_simple_triggers.py
python process_dialogs.py
python process_global_variables_unused.py
python process_postfx.py
@del *.pyc
echo.
echo ______________________________
echo.
python unused_items.py
echo Script processing has ended.
echo Press any key to exit. . .
pause>nul

or if you prefer, you can just run it from command line. Shift-Right Click the directory, then "open command line here", and type in the line above.

This is the output for native items, 210 items that no troops have equipped

no_item
tutorial_dagger
horse_meat
heavy_practice_sword
practice_dagger
practice_axe
arena_axe
arena_sword
arena_sword_two_handed
arena_lance
practice_lance
practice_bow
practice_crossbow
practice_javelin
practice_javelin_melee
practice_throwing_daggers
practice_throwing_daggers_100_amount
practice_horse
practice_arrows
practice_bolts
practice_arrows_10_amount
practice_arrows_100_amount
practice_bolts_9_amount
practice_boots
red_tourney_armor
blue_tourney_armor
green_tourney_armor
gold_tourney_armor
red_tourney_helmet
blue_tourney_helmet
green_tourney_helmet
gold_tourney_helmet
arena_shield_red
arena_shield_blue
arena_shield_green
arena_shield_yellow
arena_armor_white
arena_armor_blue
arena_armor_green
arena_armor_yellow
arena_tunic_yellow
arena_helmet_red
arena_helmet_blue
arena_helmet_green
arena_helmet_yellow
steppe_helmet_white
steppe_helmet_red
steppe_helmet_blue
steppe_helmet_green
steppe_helmet_yellow
tourney_helm_white
tourney_helm_red
tourney_helm_blue
tourney_helm_green
tourney_helm_yellow
arena_turban_red
arena_turban_blue
arena_turban_green
arena_turban_yellow
spice
salt
oil
pottery
raw_flax
linen
wool
wool_cloth
raw_silk
raw_dyes
velvet
iron
tools
raw_leather
leatherwork
raw_date_fruit
wine
ale
smoked_fish
cheese
honey
sausages
cabbages
dried_meat
fruit
raw_grapes
raw_olives
grain
cattle_meat
bread
chicken
pork
butter
siege_supply
quest_wine
quest_ale
tutorial_saddle_horse
tutorial_shield
tutorial_staff_no_attack
tutorial_staff
cartridges
pilgrim_hood
black_greaves
sarranid_head_cloth_b
lady_dress_blue
khergit_lady_dress
khergit_lady_dress_b
coat
leather_coat
mail_coat
long_mail_coat
hide_coat
merchant_outfit
homespun_dress
thick_coat
coat_with_cape
steppe_outfit
nordic_outfit
nordic_armor
hide_armor
cloaked_tunic
sleeveless_tunic
sleeveless_leather_tunic
linen_shirt
wool_coat
black_armor
pelt_coat
sarranid_dress_b
burlap_tunic
heraldic_mail_with_tunic
heraldic_mail_with_tunic_b
turret_hat_blue
turret_hat_green
court_hat
hood_b
hood_c
hood_d
khergit_lady_hat
khergit_lady_hat_b
black_helmet
wooden_stick
hammer
arabian_sword_d
sword_of_war
two_handed_cleaver
military_cleaver_b
military_sickle_a
two_handed_battle_axe_2
shortened_voulge
long_axe_alt
long_axe_b
long_axe_b_alt
long_axe_c
long_axe_c_alt
long_bardiche
great_long_bardiche
sword_medieval_c_long
mace_2
long_spiked_club
long_hafted_spiked_mace
sarranid_mace_1
sarranid_axe_b
sarranid_two_handed_axe_b
military_fork
jousting_lance
double_sided_lance
poleaxe
polehammer
military_scythe
great_lance
awlpike_long
bec_de_corbin_a
shield_heater_c
norman_shield_1
norman_shield_2
norman_shield_3
norman_shield_4
norman_shield_5
norman_shield_6
norman_shield_7
norman_shield_8
darts
war_darts
javelin_melee
throwing_spear_melee
jarid_melee
light_throwing_axes_melee
throwing_axes_melee
heavy_throwing_axes_melee
flintlock_pistol
torch
felt_steppe_cap
khergit_helmet
khergit_guard_boots
light_leather
light_mail_and_plate
byzantion_helmet_a
magyar_helmet_a
rus_helmet_a
sipahi_helmet_a
shahi
rabati
keys
bride_dress
bride_crown
bride_shoes
practice_bow_2
practice_arrows_2
heraldic_mail_with_surcoat_for_tableau
mail_boots_for_tableau
items_end
 
Nice script. It would be nice to know which items only have 1-2 uses as well.
Are there any new scripts here for counting the inventory weight of individual troops and then applying penalties to that?
What about the inventory weight of an entire party including (or excluding) equipped items?

I have the floris source code but something seems off.
 
Lav said:
Anyway, here's an updated version of the script. Context menus are used to select the party to move. TFGH buttons are used to move party around, instead of WASD, so no more conflicts with normal map scrolling. Finally, terrain restrictions apply - you cannot move party over water or mountains (but you can move Praven over a bridge :wink:).

Code:
    (0,
        [
            (map_free),
            (neq, "$g_controlled_party", 0),
            (party_is_active, "$g_controlled_party"),
            (set_fixed_point_multiplier, 1000),
            (party_get_position, pos60, "$g_controlled_party"),
            (position_get_x, ":dx", pos60),
            (position_get_y, ":dy", pos60),
            (assign, ":movement", 0),
            (assign, ":d", 200),
            (try_begin),
                (this_or_next|key_is_down, key_left_control),
                (key_is_down, key_right_control),
                (val_div, ":d", 10),
            (else_try),
                (this_or_next|key_is_down, key_left_shift),
                (key_is_down, key_right_shift),
                (val_mul, ":d", 5),
            (try_end),
            (try_begin),
                (key_is_down, key_t),
                (val_add, ":dy", ":d"),
                (assign, ":movement", 1),
            (try_end),
            (try_begin),
                (key_is_down, key_g),
                (val_sub, ":dy", ":d"),
                (assign, ":movement", 1),
            (try_end),
            (try_begin),
                (key_is_down, key_f),
                (val_sub, ":dx", ":d"),
                (assign, ":movement", 1),
            (try_end),
            (try_begin),
                (key_is_down, key_h),
                (val_add, ":dx", ":d"),
                (assign, ":movement", 1),
            (try_end),
            (eq, ":movement", 1),
            (init_position, pos61),
            (position_set_x, pos61, ":dx"),
            (position_set_y, pos61, ":dy"),
            (party_set_position, "$g_controlled_party", pos61),
            (try_begin),
                (party_get_current_terrain, ":terrain", "$g_controlled_party"),
                (this_or_next|eq, ":terrain", 0),
                (this_or_next|eq, ":terrain", 1),
                (this_or_next|eq, ":terrain", 8),
                (eq, ":terrain", 9),
                (party_set_position, "$g_controlled_party", pos60),
            (try_end),
            (set_camera_follow_party, "$g_controlled_party"),
        ]
    ),
Code:
  #script_game_context_menu_get_buttons:
  # This script is called from the game engine when the player clicks the right mouse button over a party on the map.
  # INPUT: arg1 = party_no
  # OUTPUT: none, fills the menu buttons
  ("game_context_menu_get_buttons",
   [
     (store_script_param, ":party_no", 1),
     (try_begin),
       (neq, ":party_no", "p_main_party"),
       (context_menu_add_item, "@Move here", cmenu_move),
     (try_end),
        
     (try_begin),
       (is_between, ":party_no", centers_begin, centers_end),
       (context_menu_add_item, "@View notes", 1),
     (else_try),
       (party_get_num_companion_stacks, ":num_stacks", ":party_no"),
       (gt, ":num_stacks", 0),
       (party_stack_get_troop_id, ":troop_no", ":party_no", 0),
       (is_between, ":troop_no", active_npcs_begin, active_npcs_end),
       (context_menu_add_item, "@View notes", 2),
     (try_end),

     (try_begin),
       (eq, ":party_no", "$g_controlled_party"),
       (context_menu_add_item, "@Accept this position", 3),
     (else_try),
       (context_menu_add_item, "@Manipulate this party", 3),
     (try_end),

     (try_begin),
       (neq, ":party_no", "p_main_party"),       
       (store_faction_of_party, ":party_faction", ":party_no"),
                     
       (this_or_next|eq, ":party_faction", "$players_kingdom"),
       (this_or_next|eq, ":party_faction", "fac_player_supporters_faction"),
       (party_slot_eq, ":party_no", slot_party_type, spt_kingdom_caravan),
       
       (neg|is_between, ":party_no", centers_begin, centers_end),
       
       (context_menu_add_item, "@Accompany", cmenu_follow), 
     (try_end),    
  ]),

  #script_game_event_context_menu_button_clicked:
  # This script is called from the game engine when the player clicks on a button at the right mouse menu.
  # INPUT: arg1 = party_no, arg2 = button_value
  # OUTPUT: none
  ("game_event_context_menu_button_clicked",
   [(store_script_param, ":party_no", 1),
    (store_script_param, ":button_value", 2),
    (try_begin),
      (eq, ":button_value", 1),
      (change_screen_notes, 3, ":party_no"),
    (else_try),
      (eq, ":button_value", 2),
      (party_stack_get_troop_id, ":troop_no", ":party_no", 0),
      (change_screen_notes, 1, ":troop_no"),
    (else_try),
      (eq, ":button_value", 3),
      (try_begin),
        (eq, ":party_no", "$g_controlled_party"),
        (assign, "$g_controlled_party", 0),
        (display_message, "@New party coordinates set."),
      (else_try),
        (assign, "$g_controlled_party", ":party_no"),
        (display_message, "@Party manipulation started, move it using TFGH keys."),
      (try_end),
    (try_end),
  ]),

Hello, I came across this while looking for a different map editor choice. I am only intermediate with python and am curious how would I go about using this piece of script to actually edit the map in a live environment? Like do I need to make it draw a box on the screen in order to use a GUI? Obviously im very lost here, please help lol :smile:
 
Sorenerv said:
Hello, I came across this while looking for a different map editor choice. I am only intermediate with python and am curious how would I go about using this piece of script to actually edit the map in a live environment? Like do I need to make it draw a box on the screen in order to use a GUI? Obviously im very lost here, please help lol :smile:
There isn't a single line of Python in there, God damn it! The game uses a custom scripting language that gets processed through Python; this allows for limited Python usage, chiefly for compile-time code generation. One usually ends up not using real Python for almost absolutely everything that's related to modding this game.
Yes, I know how the thread's named, but that still changes nothing.

This aside, you can't "use a GUI" on the world map. As Lav states in the post you quoted, you select a party to move using the context menu (the bits you add to
Code:
module_scripts
are related to that), then use TFGH to move the party around. I think you then use the context menu of your selected party to confirm the new position and cancel the movement mode.
 
Back
Top Bottom