PYTHON SCRIPT/SCHEME EXCHANGE

Users who are viewing this thread

CheeseNIP said:
Okay Im a bit of a nub, and Im trying to set this up and for the life of me I cannot figure this out.
where is module_dialogs.py at?
You need to download the module system and get it set up. See the stickied threads in The Forge and the Unofficial Tutorials and Documentation sub-boards.
 
Belendor 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.

Hey I hope you don't mind if i use this code for a mod I'm working on? By the way, how do you changed the king's native response when asking about an alliance (marriage into family)? Beings all the kings now have eligible bachelors/bachelorettes for children, it would be nice to marry into royalty, that and the option for eligible marry-able npc's has drastically dropped due to each king have like 3+ daughters. :sad:
 
I'm trying to make new features, "Buy Fief in Siege" from the enemy.
The price is variable, you pay them, enemy will leave the castle  :mrgreen:
If there are 223 mens of the enemy inside the castle, you must pay 22300 denars for them to leave, the multiplier is 100
Its mean 100 denars/men  :???:

  ##Exa Native - Buy Fief in Siege
  [anyone|plyr,"player_siege_castle_commander_1", [], "No more bloodshed for us in this place. I'll buy this fief.", "player_siege_buy_fief", []],


  [anyone,"player_siege_buy_fief", [(lt, "$g_talk_troop_faction_relation", -60),],    "Never, A glory can't be exchange for money.", "close_window", []], # This is the response if you are too much hated by the enemy, just delete this if you doesn't want this
  [anyone,"player_siege_buy_fief",
[(assign, reg3, "$g_enemy_fit_for_battle"),
    (store_mul,"$g_enemy_need_money","$g_enemy_fit_for_battle",100), #This is the multiplier, just change if it too much
(store_troop_gold,"$g_player_gold",trp_player),
(assign, reg2,"$g_enemy_need_money"),
],    "Give us {reg2} denars for {reg3} people as final salary, I'm sure they will be disbanded in peace", "player_siege_buy_fief_response", []],


        [anyone|plyr,"player_siege_buy_fief_response", [(ge,"$g_player_gold","$g_enemy_need_money"),],  "Sure, for live of my troops and your troops", "player_siege_buy_fief_2",
[ (troop_remove_gold, "trp_player", "$g_enemy_need_money"),
(val_add, "$g_talk_troop_faction_relation", 3),
        (assign, "$g_next_menu", "mnu_castle_taken"),
        (jump_to_menu, "mnu_total_victory"),]],

        [anyone|plyr,"player_siege_buy_fief_response", [(assign, reg2,"$g_enemy_need_money"),],  "{reg2} denars?! Neverminds", "close_window", []],


        [anyone,"player_siege_buy_fief_2", [],    "Like I said before, We will leave this place in peace", "close_window", []],
  ##Exa Native - Buy Fief in Siege Ends
 
I always liked the idea of being able how much you hit in SP, here is a rough design for MP.

Code:
damage_value = (
  ti_on_agent_hit, 0, 0, [],
  [  (store_trigger_param_1, ":receiver"),
     (store_trigger_param_2, ":dealer"),
     (store_trigger_param_3, ":damage"),

      (assign, reg19, ":damage"),
      (multiplayer_get_my_player, ":player"),
       (try_begin),
       (eq, ":dealer", ":player"),      
        (display_message, "@Delivered {reg19} damage.", 0xFFAAFFAA),
       (else_try),
       (eq, ":receiver", ":player"),
        (display_message, "@Received {reg19} damage.", 0xFF7A4800),
       (try_end),

         
    ])
 
A small script for pure fun. Codename "Hand of God".

Script allows you to relocate towns, castles, villages and pretty much anything on the world map at will.

Additional trigger can be implemented to dump all active parties with their coordinates with (display_debug_message) to rgl_log file - and you have a working party editor. :smile:

Code:
	(0,
		[
			(map_free),
			(eq, "$g_god_mode", 0),
			(key_clicked, key_g),
			(assign, "$g_god_mode", 1),
			(assign, "$g_god_hand", -1),
			(party_get_position, pos60, "p_main_party"),
			(party_set_position, "p_main_party", pos60),
			(party_set_ai_behavior, "p_main_party", ai_bhvr_hold),
			(display_message, "@{!}GOD MODE ON"),
		]
	),

	(0,
		[
			(map_free),
			(eq, "$g_god_mode", 1),
			(key_clicked, key_h),
			(assign, "$g_god_mode", 0),
			(assign, "$g_god_hand", -1),
			(display_message, "@{!}GOD MODE OFF"),
			(set_camera_follow_party, "p_main_party"),
		]
	),

	(0,
		[
			(map_free),
			(eq, "$g_god_mode", 1),
			(get_party_ai_current_behavior, ":behavior", "p_main_party"),
			(eq, ":behavior", ai_bhvr_attack_party),
			(get_party_ai_current_object, ":new_target", "p_main_party"),
			(neq, "$g_god_hand", ":new_target"),
			(assign, "$g_god_hand", ":new_target"),
			(party_get_position, pos60, "p_main_party"),
			(party_set_position, "p_main_party", pos60),
			(party_set_ai_behavior, "p_main_party", ai_bhvr_hold),
			(str_store_party_name, s9, "$g_god_hand"),
			(display_message, "@{!}Fate of {s9} is now in the hands of the God."),
		]
	),

	(0,
		[
			(map_free),
			(eq, "$g_god_mode", 1),
			(neq, "$g_god_hand", -1),
			(party_is_active, "$g_god_hand"),
			(set_fixed_point_multiplier, 1000),
			(party_get_position, pos60, "$g_god_hand"),
			(position_get_x, ":dx", pos60),
			(position_get_y, ":dy", pos60),
			(assign, ":movement", 0),
			(assign, ":d", 200),
			(try_begin),
				(key_is_down, key_left_control),
				(val_div, ":d", 10),
			(else_try),
				(key_is_down, key_left_shift),
				(val_mul, ":d", 5),
			(try_end),
			(try_begin),
				(game_key_is_down, gk_move_forward),
				(val_add, ":dy", ":d"),
				(assign, ":movement", 1),
				(omit_key_once, gk_move_forward),
			(try_end),
			(try_begin),
				(game_key_is_down, gk_move_backward),
				(val_sub, ":dy", ":d"),
				(assign, ":movement", 1),
				(omit_key_once, gk_move_backward),
			(try_end),
			(try_begin),
				(game_key_is_down, gk_move_left),
				(val_sub, ":dx", ":d"),
				(assign, ":movement", 1),
				(omit_key_once, gk_move_left),
			(try_end),
			(try_begin),
				(game_key_is_down, gk_move_right),
				(val_add, ":dx", ":d"),
				(assign, ":movement", 1),
				(omit_key_once, gk_move_right),
			(try_end),
			(try_begin),
				(eq, ":movement", 1),
				(position_set_x, pos60, ":dx"),
				(position_set_y, pos60, ":dy"),
				(party_set_position, "$g_god_hand", pos60),
			(try_end),
			(set_camera_follow_party, "$g_god_hand"),
		]
	),
To activate god mode, press G (for god).

To leave god mode, press H (for human).

To select a party on the world map, just click on it.

After that, use WASD to move the party around.

Hold left Ctrl for slower party movement and more precise control.

Hold left Shift for faster party movement.
 
Lav said:
A small script for pure fun. Codename "Hand of God".

Script allows you to relocate towns, castles, villages and pretty much anything on the world map at will.

Additional trigger can be implemented to dump all active parties with their coordinates with (display_debug_message) to rgl_log file - and you have a working party editor. :smile:

Code:
	(0,
		[
			(map_free),
			(eq, "$g_god_mode", 0),
			(key_clicked, key_g),
			(assign, "$g_god_mode", 1),
			(assign, "$g_god_hand", -1),
			(party_get_position, pos60, "p_main_party"),
			(party_set_position, "p_main_party", pos60),
			(party_set_ai_behavior, "p_main_party", ai_bhvr_hold),
			(display_message, "@{!}GOD MODE ON"),
		]
	),

	(0,
		[
			(map_free),
			(eq, "$g_god_mode", 1),
			(key_clicked, key_h),
			(assign, "$g_god_mode", 0),
			(assign, "$g_god_hand", -1),
			(display_message, "@{!}GOD MODE OFF"),
			(set_camera_follow_party, "p_main_party"),
		]
	),

	(0,
		[
			(map_free),
			(eq, "$g_god_mode", 1),
			(get_party_ai_current_behavior, ":behavior", "p_main_party"),
			(eq, ":behavior", ai_bhvr_attack_party),
			(get_party_ai_current_object, ":new_target", "p_main_party"),
			(neq, "$g_god_hand", ":new_target"),
			(assign, "$g_god_hand", ":new_target"),
			(party_get_position, pos60, "p_main_party"),
			(party_set_position, "p_main_party", pos60),
			(party_set_ai_behavior, "p_main_party", ai_bhvr_hold),
			(str_store_party_name, s9, "$g_god_hand"),
			(display_message, "@{!}Fate of {s9} is now in the hands of the God."),
		]
	),

	(0,
		[
			(map_free),
			(eq, "$g_god_mode", 1),
			(neq, "$g_god_hand", -1),
			(party_is_active, "$g_god_hand"),
			(set_fixed_point_multiplier, 1000),
			(party_get_position, pos60, "$g_god_hand"),
			(position_get_x, ":dx", pos60),
			(position_get_y, ":dy", pos60),
			(assign, ":movement", 0),
			(assign, ":d", 200),
			(try_begin),
				(key_is_down, key_left_control),
				(val_div, ":d", 10),
			(else_try),
				(key_is_down, key_left_shift),
				(val_mul, ":d", 5),
			(try_end),
			(try_begin),
				(game_key_is_down, gk_move_forward),
				(val_add, ":dy", ":d"),
				(assign, ":movement", 1),
				(omit_key_once, gk_move_forward),
			(try_end),
			(try_begin),
				(game_key_is_down, gk_move_backward),
				(val_sub, ":dy", ":d"),
				(assign, ":movement", 1),
				(omit_key_once, gk_move_backward),
			(try_end),
			(try_begin),
				(game_key_is_down, gk_move_left),
				(val_sub, ":dx", ":d"),
				(assign, ":movement", 1),
				(omit_key_once, gk_move_left),
			(try_end),
			(try_begin),
				(game_key_is_down, gk_move_right),
				(val_add, ":dx", ":d"),
				(assign, ":movement", 1),
				(omit_key_once, gk_move_right),
			(try_end),
			(try_begin),
				(eq, ":movement", 1),
				(position_set_x, pos60, ":dx"),
				(position_set_y, pos60, ":dy"),
				(party_set_position, "$g_god_hand", pos60),
			(try_end),
			(set_camera_follow_party, "$g_god_hand"),
		]
	),
To activate god mode, press G (for god).

To leave god mode, press H (for human).

To select a party on the world map, just click on it.

After that, use WASD to move the party around.

Hold left Ctrl for slower party movement and more precise control.

Hold left Shift for faster party movement.
Wonderful idea. Thanks for sharing. A little suggestion,  we need the ability to rotate them too.
 
dunde said:
Wonderful idea. Thanks for sharing. A little suggestion,  we need the ability to rotate them too.
Unfortunately, we cannot. I tried. Warband does not provide information about party rotation, and does not allow to set it. :sad:

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),
  ]),
 
Displaying WSE version on main menu :
Code:
("game_start",prsntf_read_only,0,
 [(ti_on_presentation_load,
   [(presentation_set_duration, 999999),
    (try_begin),
      (neg|is_vanilla_warband),
      (set_fixed_point_multiplier, 1000),
      (position_set_x, pos1, 218),(position_set_y, pos1, 520),
      (position_set_x, pos2, 800), (position_set_y, pos2, 800),
      (store_wse_version, reg0, 0),
      (store_wse_version, reg1, 1),
      (store_wse_version, reg2, 2),
      (create_text_overlay,  reg3, "@WSE v{reg0}.{reg1}.{reg2}", tf_right_align|tf_vertical_align_center),
      (overlay_set_position, reg3, pos1), (overlay_set_size, reg3, pos2),       
    (try_end),  ]), ]),
 
rubik said:
There is a big problem about upgrading the regulars all the time that you can only upgrade them one by one. If 100  regulars can upgrade, you need to click left mouse button 100 times.

I have write some code to solve the problem.

Source code:

At first, define slot_root_troop in module_constants.py, it is a troop slot. make sure it does not clash with your mod's other slot usage.

Paste the following into module_scripts.py
########################################################
## Easy regulars upgrading kit begin
########################################################
("calculate_upgrade_troops",
  [
    (call_script, "script_party_copy", "p_temp_party", "p_main_party"), ## before
    ## upgrade all troops in first upgrade path with total 1 xp
    ## everyone get 0 xp at last, but they all upgraded
    (party_upgrade_with_xp, "p_main_party", 1, 1),
    (call_script, "script_party_copy", "p_temp_party_2", "p_main_party"), ## after
   
    ## remove prisoners and heroes
    (call_script, "script_party_remove_all_prisoners", "p_temp_party"),
    (call_script, "script_party_remove_all_prisoners", "p_temp_party_2"),
    (call_script, "script_party_remove_heroes", "p_temp_party"),
    (call_script, "script_party_remove_heroes", "p_temp_party_2"),
   
    ## Initialize trp_temp_array_a, trp_temp_array_b, trp_temp_array_c
    (try_for_range, ":slot_no", 0, 32),
      (troop_set_slot, "trp_temp_array_a", ":slot_no", -1),
      (troop_set_slot, "trp_temp_array_b", ":slot_no", 0),
      (troop_set_slot, "trp_temp_array_c", ":slot_no", 0),
    (try_end),
   
    (assign, ":slot_id", 0),
    (assign, ":num_times", 1),
    (try_for_range, ":unused", 0, ":num_times"),
      ## find all current root troops
      (party_get_num_companion_stacks, ":num_stacks", "p_temp_party"),
      (try_for_range, ":cur_stack", 0, ":num_stacks"),
        (party_stack_get_troop_id, ":cur_troop", "p_temp_party", ":cur_stack"),
        (troop_set_slot, ":cur_troop", slot_root_troop, 1),
      (try_end),
     
      (try_for_range, ":cur_stack", 0, ":num_stacks"),
        (party_stack_get_troop_id, ":cur_troop", "p_temp_party", ":cur_stack"),
        (troop_get_upgrade_troop, ":upgrade_troop", ":cur_troop", 0),
        (gt, ":upgrade_troop", 0),
        (call_script, "script_party_has_troop", "p_temp_party", ":upgrade_troop"),
        (eq, reg0, 1),
        (troop_set_slot, ":upgrade_troop", slot_root_troop, 0), ## not a root troop
      (try_end),
     
      ## calculate upgrade troops and upgrade size
      (try_for_range_backwards, ":cur_stack", 0, ":num_stacks"),
        (party_stack_get_troop_id, ":cur_troop", "p_temp_party", ":cur_stack"),
        (gt, ":cur_troop", 0),
        (troop_slot_eq, ":cur_troop", slot_root_troop, 1),
        (party_stack_get_size, ":stack_size", "p_temp_party", ":cur_stack"),
       
        (call_script, "script_party_has_troop", "p_temp_party_2", ":cur_troop"),
        (try_begin),
          (eq, reg0, 0),
          (assign, ":stack_size_2", 0),
        (else_try),
          (party_get_num_companion_stacks, ":num_stacks_2", "p_temp_party_2"),
          (try_for_range, ":cur_stack_2", 0, ":num_stacks_2"),
            (party_stack_get_troop_id, ":cur_troop_2", "p_temp_party_2", ":cur_stack_2"),
            (eq, ":cur_troop_2", ":cur_troop"),
            (party_stack_get_size, ":stack_size_2", "p_temp_party_2", ":cur_stack_2"),
          (try_end),
        (try_end),
       
        (try_begin),
          (val_sub, ":stack_size", ":stack_size_2"),
          (gt, ":stack_size", 0),
          ## reduce the first upgrade path size
          (troop_get_upgrade_troop, ":upgrade_troop", ":cur_troop", 0),
          (party_remove_members, "p_temp_party_2", ":upgrade_troop", ":stack_size"),
          ## reduce the first upgrade path size
          (troop_set_slot, "trp_temp_array_a", ":slot_id", ":cur_troop"), ## troop which can upgrade
          (troop_set_slot, "trp_temp_array_b", ":slot_id", ":stack_size"), ## troop upgrade size
          (troop_set_slot, "trp_temp_array_c", ":slot_id", 0), ## troop upgrade second path size
          (val_add, ":slot_id", 1),
        (try_end),
       
        ## remove current root troop
        (call_script, "script_party_remove_troop", "p_temp_party", ":cur_troop"),
        (call_script, "script_party_remove_troop", "p_temp_party_2", ":cur_troop"),
      (try_end),
     
      ## do the loop once more?
      (try_begin),
        (party_get_num_companion_stacks, ":num_stacks", "p_temp_party"),
        (gt, ":num_stacks", 0),
        (val_add, ":num_times", 1), ## once more
      (try_end),
    (try_end),
  ]),

("party_has_troop",
  [
    (store_script_param_1, ":party_no"),
    (store_script_param_2, ":troop_no"),
   
    (assign, reg0, 0),
    (party_get_num_companion_stacks, ":num_stacks", ":party_no"),
    (try_for_range, ":cur_stack", 0, ":num_stacks"),
      (party_stack_get_troop_id, ":cur_troop", ":party_no", ":cur_stack"),
      (eq, ":cur_troop", ":troop_no"),
      (assign, reg0, 1),
      (assign, ":num_stacks", 0), #end the loop
    (try_end),
  ]),

("party_remove_troop",
  [
    (store_script_param_1, ":party_no"),
    (store_script_param_2, ":troop_no"),
   
    (party_get_num_companion_stacks, ":num_stacks", ":party_no"),
    (try_for_range, ":cur_stack", 0, ":num_stacks"),
      (party_stack_get_troop_id, ":cur_troop", ":party_no", ":cur_stack"),
      (eq, ":cur_troop", ":troop_no"),
      (party_stack_get_size, ":stack_size", ":party_no", ":cur_stack"),
      (party_remove_members, ":party_no", ":troop_no", ":stack_size"),
    (try_end),
  ]),

("party_remove_heroes",
  [
    (store_script_param_1, ":party_no"),
   
    (party_get_num_companion_stacks, ":num_stacks", ":party_no"),
    (try_for_range_backwards, ":cur_stack", 0, ":num_stacks"),
      (party_stack_get_troop_id, ":cur_troop", ":party_no", ":cur_stack"),
      (troop_is_hero, ":cur_troop"),
      (party_remove_members, ":party_no", ":cur_troop", 1),
    (try_end),
  ]),

("has_enough_slot",
  [
    (party_clear, "p_temp_party"),
    (party_get_num_companion_stacks, ":num_stacks", "p_main_party"),
    (try_for_range, ":stack_no", 0, ":num_stacks"),
      (party_stack_get_troop_id, ":cur_troop", "p_main_party", ":stack_no"),
      (try_begin),
        (troop_get_upgrade_troop, ":upgraded_troop_1", ":cur_troop", 0),
        (gt, ":upgraded_troop_1", 0),
        (neg|main_party_has_troop, ":upgraded_troop_1"),
        (party_add_members, "p_temp_party", ":upgraded_troop_1", 1),
      (else_try),
        (troop_get_upgrade_troop, ":upgraded_troop_2", ":cur_troop", 1),
        (gt, ":upgraded_troop_2", 0),
        (neg|main_party_has_troop, ":upgraded_troop_2"),
        (party_add_members, "p_temp_party", ":upgraded_troop_2", 1),
      (try_end),
    (try_end),
    (store_num_free_stacks, ":free_stacks", "p_main_party"),
    (party_get_num_companion_stacks, ":num_stack_increase", "p_temp_party"),
   
    (try_begin),
      (ge, ":free_stacks", ":num_stack_increase"),
      (assign, reg0, 1),
    (else_try),
      (assign, reg0, 0),
    (try_end),
  ]),
########################################################
## Easy regulars upgrading kit end
########################################################

The following into module_game_menus.py:
      ("camp_action_1",[(eq,"$cheat_mode",1)],"Cheat: Walk around.",
      [(set_jump_mission,"mt_ai_training"),
        (call_script, "script_setup_random_scene"),
        (change_screen_mission),
        ]
      ),
########################################################
## Easy regulars upgrading kit begin
########################################################
    ("camp_upgrade_troops",
      [
        (call_script, "script_has_enough_slot"),
        (eq, reg0, 1),
      ],
    "Upgrade your troops.", [(jump_to_menu, "mnu_ready_upgrade")]),
   
    ("camp_upgrade_troops_no",
      [
        (call_script, "script_has_enough_slot"),
        (eq, reg0, 0),
        (disable_menu_option),
      ],
    "No slot for upgrading.", []),
########################################################
## Easy regulars upgrading kit end
########################################################

########################################################
## Easy regulars upgrading kit begin
########################################################
  ("ready_upgrade", 0,
  "{s0}",
    "none",
    [
      ## use reg10 to record wheather can continue or not
      ## use reg11 to record the progress of upgrading
      (try_begin),
        (party_get_num_companion_stacks, ":num_stacks", "p_main_party"),
        (eq, ":num_stacks", 1),
        (str_store_string, s0, "@ No one can upgrade."),
        (assign, reg10, 0),
      (else_try),
        (call_script, "script_calculate_upgrade_troops"),
        (try_begin),
          (troop_slot_eq, "trp_temp_array_a", 0, -1),
          (str_store_string, s0, "@ No one can upgrade."),
          (assign, reg10, 0),
        (else_try),
          (assign, reg10, 1),
          (assign, ":kinds_of_upgrade_troop", 0),
          (try_for_range, ":slot_id", 0, 32),
            (troop_get_slot, ":upgrade_troop", "trp_temp_array_a", ":slot_id"),
            (troop_get_slot, ":upgrade_size", "trp_temp_array_b", ":slot_id"),
            (gt, ":upgrade_troop", 0),
            (try_begin),
              (eq, ":kinds_of_upgrade_troop", 0),
              (str_store_troop_name_by_count, s1, ":upgrade_troop", ":upgrade_size"),
              (assign, reg1, ":upgrade_size"),
              (str_store_string, s0, "@{reg1} {s1} can upgrade."),
            (else_try),
              (eq, ":kinds_of_upgrade_troop", 1),
              (str_store_troop_name_by_count, s1, ":upgrade_troop", ":upgrade_size"),
              (assign, reg1, ":upgrade_size"),
              (str_store_string, s0, "@{reg1} {s1} and {s0}"),
            (else_try),
              (str_store_troop_name_by_count, s1, ":upgrade_troop", ":upgrade_size"),
              (assign, reg1, ":upgrade_size"),
              (str_store_string, s0, "@{reg1} {s1}, {s0}"),
            (try_end),
            (val_add, ":kinds_of_upgrade_troop", 1),
          (try_end),
        (try_end),
      (try_end),
    ],
    [
      ("upgrade_back", [(eq, reg10, 0)],
        "Go back.",
        [(jump_to_menu, "mnu_camp")]
      ),
     
      ("upgrade_continue", [(eq, reg10, 1)],
        "Continue...",
        [
          (jump_to_menu, "mnu_camp"),
          (assign, reg11, 0),
          (start_presentation, "prsnt_upgrade_troops"),
        ]
      ),
    ]
  ),
########################################################
## Easy regulars upgrading kit end
########################################################

The following into module_presentations.py:
########################################################   
## Easy regulars upgrading kit begin
########################################################
  ("upgrade_troops", 0, mesh_load_window, [
  (ti_on_presentation_load,
    [
      (set_fixed_point_multiplier, 1000),
      (presentation_set_duration, 999999),
     
      (assign, ":slot_id", reg11),
      ## upgrade troop and total size
      # upgrade size will not change
      (troop_get_slot, ":upgrade_troop", "trp_temp_array_a", ":slot_id"),
      (troop_get_slot, ":upgrade_size", "trp_temp_array_b", ":slot_id"),
      (str_store_troop_name_by_count, s0, ":upgrade_troop", ":upgrade_size"),
      (assign, reg3, ":upgrade_size"),
     
      ## upgrade 2nd path: troop and size
      (troop_get_slot, ":upgrade_2_size", "trp_temp_array_c", ":slot_id"),
      (troop_get_upgrade_troop, ":upgrade_2_troop", ":upgrade_troop", 1),
      (try_begin),
        (gt, ":upgrade_2_troop", 0),
        (str_store_troop_name, s2, ":upgrade_2_troop"),
        (assign, reg2, ":upgrade_2_size"),
      (try_end),
     
      ## upgrade 1st path: troop and size
      (troop_get_upgrade_troop, ":upgrade_1_troop", ":upgrade_troop", 0),
      # upgrade 1 size = upgrade size - upgrade 2 size
      (store_sub, ":upgrade_1_size", ":upgrade_size", ":upgrade_2_size"),
      (str_store_troop_name, s1, ":upgrade_1_troop"),
      (assign, reg1, ":upgrade_1_size"),
     
      (create_text_overlay, reg0, "@{reg3} {s0} can upgrade.", tf_center_justify|tf_vertical_align_center),
      (position_set_x, pos1, 500),
      (position_set_y, pos1, 450),
      (overlay_set_position, reg0, pos1),
     
      (try_begin),
        (gt, ":upgrade_2_troop", 0),
        (create_text_overlay, "$g_presentation_obj_1", "@{reg1}^^Upgrade to {s1}", tf_center_justify|tf_vertical_align_center),
        (position_set_x, pos1, 320),
        (position_set_y, pos1, 350),
        (overlay_set_position, "$g_presentation_obj_1", pos1),
       
        (create_text_overlay, "$g_presentation_obj_2", "@{reg2}^^Upgrade to {s2}", tf_center_justify|tf_vertical_align_center),
        (position_set_x, pos1, 680),
        (position_set_y, pos1, 350),
        (overlay_set_position, "$g_presentation_obj_2", pos1),
       
        (create_slider_overlay, "$g_presentation_obj_3", 0, ":upgrade_size"),
        (position_set_x, pos1, 500),
        (position_set_y, pos1, 350),
        (overlay_set_val, "$g_presentation_obj_3", ":upgrade_2_size"),
        (overlay_set_position, "$g_presentation_obj_3", pos1),
      (else_try),
        (create_text_overlay, "$g_presentation_obj_1", "@Upgrade to {s1}({reg3})", tf_center_justify|tf_vertical_align_center),
        (position_set_x, pos1, 500),
        (position_set_y, pos1, 350),
        (overlay_set_position, "$g_presentation_obj_1", pos1),
       
        (create_text_overlay, "$g_presentation_obj_2", "@ ", tf_center_justify|tf_vertical_align_center),
        (position_set_x, pos1, 1200),
        (position_set_y, pos1, 1200),
        (overlay_set_position, "$g_presentation_obj_2", pos1),
       
        (create_slider_overlay, "$g_presentation_obj_3", 0, 10),
        (position_set_x, pos1, 1200),
        (position_set_y, pos1, 1200),
        (overlay_set_val, "$g_presentation_obj_3", 0),
        (overlay_set_position, "$g_presentation_obj_3", pos1),
      (try_end),
     
      (create_button_overlay, "$g_presentation_obj_4", "@Previous"),
      (try_begin),
        (gt, reg11, 0),
        (position_set_x, pos1, 200),
        (position_set_y, pos1, 200),
      (else_try),
        (position_set_x, pos1, 1200),
        (position_set_y, pos1, 1200),
      (try_end),
      (overlay_set_position, "$g_presentation_obj_4", pos1),
     
      (position_set_x, pos1, 800),
      (position_set_y, pos1, 200),
      (store_add, ":next_slot", reg11, 1),
      (try_begin),
        (neg|troop_slot_eq, "trp_temp_array_a", ":next_slot", -1),
        (str_store_string, s0, "@Next"),
      (else_try),
        (str_store_string, s0, "@Done"),
      (try_end),
      (create_button_overlay, "$g_presentation_obj_5", "@{s0}"),
      (overlay_set_position, "$g_presentation_obj_5", pos1),
    ]),

  (ti_on_presentation_run,
    [
      (set_fixed_point_multiplier, 1000),

      (assign, ":slot_id", reg11),
      (troop_get_slot, ":upgrade_troop", "trp_temp_array_a", ":slot_id"),
      (troop_get_upgrade_troop, ":upgrade_2_troop", ":upgrade_troop", 1),
      (try_begin),
        (gt, ":upgrade_2_troop", 0),
        (troop_get_slot, ":upgrade_size", "trp_temp_array_b", ":slot_id"),
        (troop_get_slot, ":upgrade_2_size", "trp_temp_array_c", ":slot_id"),
        (assign, reg2, ":upgrade_2_size"),
        (store_sub, ":upgrade_1_size", ":upgrade_size", ":upgrade_2_size"),
        (assign, reg1, ":upgrade_1_size"),
       
        (overlay_set_text, "$g_presentation_obj_1", "@{reg1}^^Upgrade to {s1}"),
        (overlay_set_text, "$g_presentation_obj_2", "@{reg2}^^Upgrade to {s2}"),
      (try_end),
    ]),

  (ti_on_presentation_event_state_change,
    [
      (store_trigger_param_1, ":eek:bject"),
      (store_trigger_param_2, ":value"),

      (try_begin),
        (eq, ":eek:bject", "$g_presentation_obj_3"),
        (assign, ":slot_id", reg11),
        (troop_get_slot, ":upgrade_2_size", "trp_temp_array_c", ":slot_id"),
        (try_begin),
          (neq, ":upgrade_2_size", ":value"),
          (assign, ":upgrade_2_size", ":value"),
        (try_end),
        (troop_set_slot, "trp_temp_array_c", ":slot_id", ":upgrade_2_size"),
      (else_try),
        (eq, ":eek:bject", "$g_presentation_obj_4"),
        (val_sub, reg11, 1),
        (start_presentation, "prsnt_upgrade_troops"),
      (else_try),
        (eq, ":eek:bject", "$g_presentation_obj_5"),
        (store_add, ":next_slot", reg11, 1),
        (try_begin),
          (neg|troop_slot_eq, "trp_temp_array_a", ":next_slot", -1),
          (val_add, reg11, 1),
          (start_presentation, "prsnt_upgrade_troops"),
        (else_try),
          ## is the end, switch troops from 1st path to 2nd path
          (try_for_range, ":slot_id", 0, 32),
            (troop_get_slot, ":upgrade_troop", "trp_temp_array_a", ":slot_id"),
            (gt, ":upgrade_troop", 0),
            (troop_get_slot, ":upgrade_2_size", "trp_temp_array_c", ":slot_id"),
            (gt, ":upgrade_2_size", 0),
            (troop_get_upgrade_troop, ":upgrade_1_troop", ":upgrade_troop", 0),
            (troop_get_upgrade_troop, ":upgrade_2_troop", ":upgrade_troop", 1),
            (party_remove_members, "p_main_party", ":upgrade_1_troop", ":upgrade_2_size"),
            (party_add_members, "p_main_party", ":upgrade_2_troop", ":upgrade_2_size"),
          (try_end),
          ## all finished back to camp menu
          (presentation_set_duration, 0),
        (try_end),
      (try_end),
    ]),
  ]),
########################################################
## Easy regulars upgrading kit end
########################################################

screenshots:
2009629171035.jpg


2009629171053.jpg

Hi Guys,

I am new in the forum and also in Mount & Blade Scripting. I already succeed on installing Python and all, and now i am trying to make this "Fast Upgrading" troops code to work. I have a few questions regarding the code:

1. How to define "Slot_Root_Troop" in module_constants.py?
2. For codes in files: module_scripts.py, module_game_menus.py, & module_presentations.py do i have to just copy and paste it in the end of each file?

Thank you in advance :smile:
I am a newbie sorry for asking a lot
 
Xbladez said:
1. How to define "Slot_Root_Troop" in module_constants.py?
2. For codes in files: module_scripts.py, module_game_menus.py, & module_presentations.py do i have to just copy and paste it in the end of each file?
Congrats on your new ModSys.
1. Add somethng like slot_root_troop = 150 in module_constants.
rubik said:
At first, define slot_root_troop in module_constants.py, it is a troop slot. make sure it does not clash with your mod's other slot usage.
This above means to make sure that the number after slot_root_troop is different than all others after the troops slots.

2. Just look at what you've been told. The game_menus part: the first part of it shows some other code, which is a guideline for you - shows you where to put it, while the second part, lacking such guidelines, is supposed to go at the end of the file.

Good luck with modding.
 
Scared ? said:
MaverickJones said:
Updated and better version of my troop recruiting companions script :razz:
You can now choose how many troops you want to recruit

Code:
# Maverick Companion Script Start #EPIC#
  #Gain 20000 gold randomly if cheat mode is on
  [anyone|plyr,"member_question_2", [(eq,"$cheat_mode",1)], "Cheat: Could you give me some cash from that large pot of gold?", "member_moneys",[]],
  #recruit troops for a price
  [anyone|plyr,"member_question_2", [], "Could you draft in some troops for me?", "member_draft_question",[]],



  [anyone, "member_moneys", [
	    (call_script, "script_troop_add_gold", "trp_player", 20000),
		], "Sure why not, there is plenty in here", "do_member_view_char",[]],
		
  [anyone, "member_draft_question", [], "So what kind of troops do you want?", "member_draft_troop",[]],
  
  [anyone|plyr,"member_draft_troop", [], "I would like some Caravan guards.", "member_draft_troop_question2",[ (assign, "$cost_draft", 400),(assign, "$draft_id", "trp_caravan_guard"),]],
  [anyone|plyr,"member_draft_troop", [], "I would like some Watchmen.", "member_draft_troop_question2",[(assign, "$cost_draft", 200), (assign, "$draft_id", "trp_watchman")]],
  [anyone|plyr,"member_draft_troop", [], "I would like some Huntresses.", "member_draft_troop_question2",[(assign, "$cost_draft", 200), (assign, "$draft_id", "trp_hunter_woman"),]],
  [anyone|plyr,"member_draft_troop", [], "I would like some Slave Drivers.", "member_draft_troop_question2",[(assign, "$cost_draft", 200), (assign, "$draft_id", "trp_slave_driver"),]],
  [anyone|plyr,"member_draft_troop", [], "I would like some Swadian recruits.", "member_draft_troop_question2",[(assign, "$cost_draft", 150), (assign, "$draft_id", "trp_swadian_recruit"),]],
  [anyone|plyr,"member_draft_troop", [], "I would like some Veagir recruits.", "member_draft_troop_question2",[(assign, "$cost_draft", 100), (assign, "$draft_id", "trp_vaegir_recruit"),]],
  [anyone|plyr,"member_draft_troop", [], "I would like some Khergit tribesmen.", "member_draft_troop_question2",[(assign, "$cost_draft", 100), (assign, "$draft_id", "trp_khergit_tribesman"),]],
  [anyone|plyr,"member_draft_troop", [], "I would like some Nord recruits.", "member_draft_troop_question2",[(assign, "$cost_draft", 100), (assign, "$draft_id", "trp_nord_recruit"),]],
  [anyone|plyr,"member_draft_troop", [], "I would like some Rhodok tribesmen.", "member_draft_troop_question2",[(assign, "$cost_draft", 100), (assign, "$draft_id", "trp_rhodok_tribesman"),]],
  [anyone|plyr,"member_draft_troop", [], "I would like some Looters.", "member_draft_troop_question2",[(assign, "$cost_draft", 50), (assign, "$draft_id", "trp_looter"),]],
  [anyone|plyr,"member_draft_troop", [], "Never mind.", "close_window",[]],
    
  [anyone, "member_draft_troop_question2", [], "How many troops do you want?", "member_draft_troop_2",[]],
  
  [anyone|plyr,"member_draft_troop_2", [], "I would like 10.", "member_draft_troop_3",[ (assign, "$draft_num", 10)]],
  [anyone|plyr,"member_draft_troop_2", [], "I would like 9.", "member_draft_troop_3",[(assign, "$draft_num", 9)]],
  [anyone|plyr,"member_draft_troop_2", [], "I would like 8.", "member_draft_troop_3",[(assign, "$draft_num", 8)]],
  [anyone|plyr,"member_draft_troop_2", [], "I would like 7.", "member_draft_troop_3",[(assign, "$draft_num", 7)]],
  [anyone|plyr,"member_draft_troop_2", [], "I would like 6.", "member_draft_troop_3",[(assign, "$draft_num", 6)]],
  [anyone|plyr,"member_draft_troop_2", [], "I would like 5.", "member_draft_troop_3",[(assign, "$draft_num", 5)]],
  [anyone|plyr,"member_draft_troop_2", [], "I would like 4.", "member_draft_troop_3",[(assign, "$draft_num", 4)]],
  [anyone|plyr,"member_draft_troop_2", [], "I would like 3.", "member_draft_troop_3",[(assign, "$draft_num", 3)]],
  [anyone|plyr,"member_draft_troop_2", [], "I would like 2.", "member_draft_troop_3",[(assign, "$draft_num", 2)]],
  [anyone|plyr,"member_draft_troop_2", [], "I would like 1.", "member_draft_troop_3",[(assign, "$draft_num", 1)]],
  [anyone|plyr,"member_draft_troop_2", [], "Never mind.", "close_window",[]],
  
  [anyone, "member_draft_troop_3", [
  (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
     (val_min, "$draft_num", ":free_capacity"),
     (store_troop_gold, ":gold", "trp_player"),
     (store_div, ":gold_capacity", ":gold", "$cost_draft"),#denars relevant to the troop you are hiring
	 (val_min, "$draft_num", ":gold_capacity"),
     (party_add_members, "p_main_party", "$draft_id", "$draft_num"),# sets troop to the one you chose
     (store_mul, ":cost", "$draft_num", "$cost_draft"),
     (troop_remove_gold, "trp_player", ":cost"),	
	 ], "It didn't take much to convince them to join you, Hope they serve you well.", "do_member_view_char",[]],
#This new piece of script allows you to recruit from 1 to 10 troops rather than the previous locked 10 :D
 
# Maverick Companion Script End #EPIC#

How do I make so it takes 10 days before I can use this script again? Please help!


You might want to use the companion king mission time option so that you can recruit soldiers then the companion goes off to find more soldiers for 10 days.
Place this in the result section of the recruitment dialogue:
Code:
(troop_set_slot, "$g_talk_troop", slot_troop_days_on_mission, 10),
(troop_set_slot, "$g_talk_troop", slot_troop_current_mission, npc_mission_recruitsoldiers),
# (troop_set_slot, "$g_talk_troop", slot_troop_current_mission, npc_mission_kingsupport), 
(remove_member_from_party, "$g_talk_troop", "p_main_party"),
#(troop_get_slot, ":string", "$g_talk_troop", slot_troop_honorific),
#(str_store_string, s21, ":string"), ## Use if you want their name
 
Here's a little piece of useless crap code for anyone interested.
I am a weird person, and I mostly want my items' codes to fit on one line. But long
Code:
[color=navy]head_armor(0)|body_armor(26)|leg_armor(14)[/color]
definitions ruin everything. That's why I used my pathetic Python skills to make myself a custom function that shortens it up. Here it is.
To use, dump this near the top of module_items (or header_items, but I won't recommend that) around the imodbits_* definitions. This is the real function.
Code:
def hbl_armor(x, y, z):
	return head_armor(x)|body_armor(y)|leg_armor(z)
Now, everytime you want to use a shorter protection definition, you just use
Code:
[color=navy]hbl_armor(x, y, z)[/color]
, where x, y and z are the values for head armour, body armour and leg armour respectively.
And here's a working example from my own ModSys:
module_items.py said:
Code:
   ["sirath_lht_armor", "Sirathean Light Armour", [("heraldic_armor_new_b",0)], itp_sell|itp_armor|itp_covers_legs, 0, 1100, weight(12)|abundance(100)|[color=navy]hbl_armor(0,26,14)[/color]|difficulty(4), imod_lht_armor,[(ti_on_init_item, [(store_trigger_param_1, ":agent_no"),(store_trigger_param_2, ":troop_no"),(call_script, "script_shield_item_set_banner", "tableau_heraldic_armor_b", ":agent_no", ":troop_no")])]],
Yeah, I allow for heraldic placeholder-meshed items to occupy two lines of screen space. But no other exceptions!

Enjoy and have fun. If you even read/use this, which I doubt you will. The former you may do, but the latter? I wouldn't count on it.

P.S.: If, by any chance, you notice that there are
Code:
itp_sell
and
Code:
itp_armor
in the above code, that's because I defined them to be equal to itp_merchandise and itp_type_body_armor respectively. They were too long.
 
Lumos said:
Here's a little piece of useless crap code for anyone interested.
I am a weird person, and I mostly want my items' codes to fit on one line. But long
Code:
[color=navy]head_armor(0)|body_armor(26)|leg_armor(14)[/color]
definitions ruin everything. That's why I used by pathetic Python skills to make myself a custom function that shortens it up. Here it is.
To use, dump this near the top of module_items (or header_items, but I won't recommend that) around the imodbits_* definitions. This is the real function.
Code:
def hbl_armor(x, y, z):
	return head_armor(x)|body_armor(y)|leg_armor(z)
Now, everytime you want to use a shorter protection definition, you just use
Code:
[color=navy]hbl_armor(x, y, z)[/color]
, where x, y and z are the values for head armour, body armour and leg armour respectively.
And here's a working example from my own ModSys:
module_items.py said:
Code:
   ["sirath_lht_armor", "Sirathean Light Armour", [("heraldic_armor_new_b",0)], itp_sell|itp_armor|itp_covers_legs, 0, 1100, weight(12)|abundance(100)|[color=navy]hbl_armor(0,26,14)[/color]|difficulty(4), imod_lht_armor,[(ti_on_init_item, [(store_trigger_param_1, ":agent_no"),(store_trigger_param_2, ":troop_no"),(call_script, "script_shield_item_set_banner", "tableau_heraldic_armor_b", ":agent_no", ":troop_no")])]],
Yeah, I allow for heraldic placeholder-meshed items to occupy two lines of screen space. But no other exceptions!

Enjoy and have fun. If you even read/use this, which I doubt you will. The former you may do, but the latter? I wouldn't count on it.

P.S.: If, by any chance, you notice that there are
Code:
itp_sell
and
Code:
itp_armor
in the above code, that's because I defined them to be equal to itp_merchandise and itp_type_body_armor respectively. They were too long.

im sorry Lumos, im still don't understand how this code working  :sad:
 
We have id_*.py for some module_*.py. So, why can't we create one for module_constants.py? It does nothing but it may be useful to debug slot using.
I put the code into process_postfx.py as the last process_*.py called by module builder.
Code:
def remove_all_spaces_and_tabs(s0):
  s1 = string.replace(s0," ","")
  s2 = string.replace(s1,"\t","") #Tab
  s3 = string.lower(s2)
  return s3

print "Exporting id_constants.py"  
ifile = open("./module_constants.py","r")
ofile = open("./id_constants.py","w")
while 1:
    line = ifile.readline()
    if not line:
        break   
    clear_line = remove_all_spaces_and_tabs(line)
    if clear_line[0]<>"#":
      signed_line = clear_line.partition("=")
      if (signed_line[2]<>""):
        if (signed_line[0].find("slot_")==0)|(signed_line[0].endswith("begin"))|(signed_line[0].endswith("end")):
          line_is_valid = 1
          try:
            line_value = eval(signed_line[0])
          except:
            line_is_valid = 0
          if line_is_valid==1:            
            if type(line_value)==str:
              try:
                line_value_value = eval(line_value)
              except:
                line_is_valid = 0
              if line_is_valid==1:              
                ofile.write("%s %s %s\n"%(signed_line[0] + " = ", str(line_value_value)+ " # = ", line_value ))
            else:
              ofile.write("%s %s\n"%(signed_line[0]+ " = ", str(line_value)))
ifile.close()
ofile.close()

Everytime you build your mod then, id_constants.py will be created. Format of the lines of the file is :
Code:
slot_xxx = yy
xxx_begin = yy # = zzz
xxx_end = yy # = zzz
 
Lumos said:
I am a weird person, and I mostly want my items' codes to fit on one line.

It's for you, Lumos :
Code:
def ca_level(att_str=0,att_agi=0,att_int=0,att_cha=0):
  ca_out = bignum
  ca_out|= att_str
  ca_out|= att_agi << (1*8)
  ca_out|= att_int << (2*8)
  ca_out|= att_cha << (3*8)
  return ca_out

Code:
def knows_skill(skl,skl_level):
  return skl_level << (skl*4)

def knows_skills(skl_list):
  out_value = 0
  for i in xrange(len(skl_list)):
    skl       = skl_list[i][0]
    skl_level = skl_list[i][1]
    out_value |= knows_skill(skl,skl_level)
  return out_value

Usage :
1. Replace :
knows_ironflesh_3|knows_power_strike_2|knows_athletics_2|knows_riding_2|knows_shield_3
with:
knows_skills([(skl_ironflesh,3),(skl_power_strike,2),(skl_athletics,2),(skl_riding,2),(skl_shield,3)])

2. Replace :
str_5|agi_7|int_4|cha_4
with:
ca_level(5,7,4,4)
 
Hey guys :grin: I wanted to make a script, which moves a scene_prop of the type "siege_wall_a", when the winch_b Var2, is 1 :grin: but I get this error code :

Code:
   from module_scripts import *
 File "E:\WFaS Module_system 1.143\module_scripts.py", line 1989, in <module>
   (assign, ":effected_object", "spr_siege_wall_a"),
typeError: 'tuple' object is not callable
traceback (most recent call last):
 File "process_global_variables_unused.py", line 3, in <module>
   from process_operations import *
 File "E:\WFaS Module_system 1.143\process_operations.py", line 20, in <module>

Thx for help :smile:
 
Back
Top Bottom