OSP Code SP Custom soldier!

Users who are viewing this thread

Korcow

Recruit
Hello friends! I came from a Korean forum
I hope you understand that English is a mess

Today is going to create a custom soldier who converted the Diplomacy script

First.
Open module_troops and paste it good place,
Code:
## korcow
["korcowmilitia", "Empire Militia", "Empire Militia", tf_male|tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_helmet|tf_guarantee_shield, no_scene, reserved, fac_commoners, [itm_spear,itm_tab_shield_kite_c,itm_blue_gambeson,itm_nomad_boots], str_10|agi_20|int_9|cha_9|level(15), wpex(65,65,65,25,25,25), knows_athletics_6, man_face_middle_1, rhodok_face_older_2 ],
["korcowsergeant", "Empire Sergeant", "Empire Sergeants", tf_male|tf_guarantee_boots|tf_guarantee_armor|tf_guarantee_helmet|tf_guarantee_shield, no_scene, reserved, fac_commoners, [itm_spear,itm_tab_shield_kite_c,itm_blue_gambeson,itm_nomad_boots], str_30|agi_20|int_9|cha_9|level(25), wpex(95,95,95,95,95,95), knows_athletics_6, man_face_middle_1, rhodok_face_older_2 ],
["korcow_end", "{!}korcow_end", "{!}korcow_end", tf_hero, 0,reserved,  fac_neutral,[itm_saddle_horse,itm_leather_jacket,itm_nomad_boots],def_attrib|level(2),wp(20),knows_common, 0x000000000008318101f390c515555594],
Second.
Open module_constant and paste good place,
Code:
korcow_man_begin  = "trp_korcowmilitia"
korcow_man_end    = "trp_korcow_end"
Third.
Open module_dialogs and paste it good place,

Code:
  [anyone|plyr,"regular_member_talk", [(is_between,"$g_talk_troop",korcow_man_begin,korcow_man_end),],					#   
   "Let me see your equipment.", "dplmc_view_regular_inventory", []
  ],
##

##
  [anyone,"dplmc_view_regular_inventory",
    [(is_between,"$g_talk_troop",korcow_man_begin,korcow_man_end),(call_script, "script_dplmc_print_subordinate_says_sir_madame_to_s0"),], "Very well {s0}, here is what I am using...", "dplmc_do_view_regular_inventory",#Use {s0} instead of {sir/madam}
    [
      (call_script, "script_dplmc_copy_inventory", "$g_player_troop", "trp_temp_array_a"),
      (call_script, "script_dplmc_copy_inventory", "$g_talk_troop", "trp_temp_array_b"),

      (try_for_range, ":i_slot", 0, 10),
        (troop_get_inventory_slot, ":item", "trp_temp_array_b", ":i_slot"),
        (gt, ":item", -1),
        (troop_get_inventory_slot_modifier, ":imod", "trp_temp_array_b", ":i_slot"),
        (troop_add_item,"trp_temp_array_b", ":item", ":imod"),
        (troop_set_inventory_slot, "trp_temp_array_b", ":i_slot", -1),
      (try_end),

    #  (change_screen_loot, "trp_temp_array_b"),
       (change_screen_equip_other),
    ]],
##
  [anyone,"dplmc_do_view_regular_inventory", [(call_script, "script_dplmc_print_subordinate_says_sir_madame_to_s0"),],#(troop_clear_inventory,<troop_id>),
   "Is that satisfactory, {s0}?", "dplmc_do_view_regular_inventory_2", []#Use {s0} instead of {sir/madam}
  ],
  [anyone|plyr,"dplmc_do_view_regular_inventory_2",
    [
      (call_script, "script_dplmc_copy_inventory", "trp_temp_array_a", "$g_player_troop"),
    ],
   "Indeed.", "do_regular_member_view_char", []
  ],
Fourth.
If you have not pitched Dplmc to write the script.

Code:
  ("dplmc_copy_inventory",
    [
      (store_script_param_1, ":source"),
      (store_script_param_2, ":target"),

      (troop_clear_inventory, ":target"),
      (troop_get_inventory_capacity, ":inv_cap", ":source"),
      (try_for_range, ":i_slot", 0, ":inv_cap"),
        (troop_get_inventory_slot, ":item", ":source", ":i_slot"),
        (troop_set_inventory_slot, ":target", ":i_slot", ":item"),
        (troop_get_inventory_slot_modifier, ":imod", ":source", ":i_slot"),
        (troop_set_inventory_slot_modifier, ":target", ":i_slot", ":imod"),
        (troop_inventory_slot_get_item_amount, ":amount", ":source", ":i_slot"),
        (gt, ":amount", 0),
        (troop_inventory_slot_set_item_amount, ":target", ":i_slot", ":amount"),
      (try_end),
    ]),
##and
    ("dplmc_print_subordinate_says_sir_madame_to_s0",
        [
        (assign, ":highest_honor", 1),#{sir/madame}
        #1: str_dplmc_sirmadame
        #2: str_dplmc_my_lordlady
        #3: str_dplmc_your_highness
        (try_begin),
            #disable extra honors when the player is not recognized
            (eq, "$sneaked_into_town", 1),
            (assign, ":highest_honor", 1),
        (else_try),
            #initialize variables for following steps
            (troop_get_slot, ":player_renown", "trp_player", slot_troop_renown),
            (troop_get_slot, ":player_spouse", "trp_player", slot_troop_spouse),
            #check if the player is the spouse of one of a widely recognized monarch,
            #or if the player is the ruler of one of the starting kingdoms (this can't happen but check anyway)
            (ge, ":player_spouse", 1),
            (try_for_range, ":faction_no", npc_kingdoms_begin, npc_kingdoms_end),
                (this_or_next|faction_slot_eq, ":faction_no", slot_faction_leader, "trp_player"),
                (faction_slot_eq, ":faction_no", slot_faction_leader, ":player_spouse"),
                (val_max, ":highest_honor", 3),
            (try_end),
            (this_or_next|is_between, ":player_spouse", kings_begin, kings_end),
            (this_or_next|is_between, ":player_spouse", pretenders_begin, pretenders_end),
                (ge, ":highest_honor", 3),
            (val_max, ":highest_honor", 3),
            #Do not continue, since you've already used the highest available honor.
        (else_try),
            #the player is head of his own faction
            (ge, "$players_kingdom", 0),
            #faction leader is player, or faction leader is spouse and spouse is valid
            (this_or_next|faction_slot_eq, "$players_kingdom", slot_faction_leader, "trp_player"),
                (faction_slot_eq, "$players_kingdom", slot_faction_leader, ":player_spouse"),
            (this_or_next|faction_slot_eq, "$players_kingdom", slot_faction_leader, "trp_player"),
                (ge, ":player_spouse", 1),

            (faction_slot_eq, "$players_kingdom", slot_faction_state, sfs_active),
            (try_begin),
                #If you have sufficient right-to-rule and renown, your subjects
                #will call you "highness".
                (ge, "$player_right_to_rule", 10),
                (store_sub, reg0, 75 + 75, "$player_right_to_rule"),
                (val_mul, reg0, 1200 // 75),#minimum required renown (as an aside, 1200 is evenly divisibly by 75)
                #examples: at right to rule 50, renown must be at least 1600
                #          at right to rule 99, renown must be at least 816
                #          at right to rule 10, renown must be at least 2240
                (ge, ":player_renown", reg0),
                (val_max, ":highest_honor", 3),
            (else_try),
                #"Highness" is also used if the player's kingdom holds meaningful territory.
                (try_begin),
                    #Recalculate the cached value if it's suspicious
                    (faction_slot_eq, "$players_kingdom", slot_faction_num_castles, 0),
                    (faction_slot_eq, "$players_kingdom", slot_faction_num_towns, 0),
                    (call_script, "script_faction_recalculate_strength", "$players_kingdom"),
                (else_try),
                    #Recalculate the cached value if it's obviously wrong
                    (this_or_next|neg|faction_slot_ge, "$players_kingdom", slot_faction_num_castles, 0),
                    (neg|faction_slot_ge, "$players_kingdom", slot_faction_num_towns, 0),
                    (call_script, "script_faction_recalculate_strength", "$players_kingdom"),
                (try_end),
                #Territory points: castles = 2, towns = 3 (ignore villages)
                (faction_get_slot, ":territory_points", "$players_kingdom", slot_faction_num_towns),
                (val_mul, ":territory_points", 3),
                (faction_get_slot, reg0, "$players_kingdom", slot_faction_num_castles),
                (val_add, ":territory_points", reg0),
                (val_add, ":territory_points", reg0),
                #If the player owns even a single center, that's worth at least "my lord" from his followers
                (ge, ":territory_points", 1),
                (val_max, ":highest_honor", 2),
                #By default there are around 48 castles and 22 towns on the map, for a total of 70
                #centers, and 162 "points" if weighting castles = 2 and towns = 3.
                (store_sub, ":global_points", towns_end, towns_begin),
                (val_mul, ":global_points", 3),
                (store_sub, reg0, castles_end, castles_begin),
                (val_add, ":global_points", reg0),
                (val_add, ":global_points", reg0),
                #By default there are 6 NPC kingdoms, averaging 8 castles and 3.66... towns or
                #27 points each (although the initial distribution of territory is not even).
                (store_sub, ":number_kingdoms", npc_kingdoms_end, npc_kingdoms_begin),
                (val_max,  ":number_kingdoms", 1),
                #Territory must be at least 3/4 the total points divided by number of initial kingdoms.
                #Right to rule applied as a percentage bonus, scaled so that you gain recognition with
                #75% right to rule and a 50% size kingdom.
                                
                #What I want is: ( (RtR * 2/3) + 100 ) * territory * kingdoms >= globe * 3/4
                #This is equivalent to: (RtR * 2 + 300) * territory * kingdoms * 4 >= globe * 9
                #The re-ordering is because of rounding.
                (store_mul, ":target_points", ":global_points", 9),
                (store_mul, reg0, "$player_right_to_rule", 2),
                (val_add, reg0, 300),
                (val_mul, reg0, ":territory_points"),
                (val_mul, reg0, ":number_kingdoms"),
                (val_mul, reg0, 4),
                (ge, reg0, ":target_points"),
                (val_max, ":highest_honor", 3),
            (try_end),
            #stop evaluation if you reached highest honor
            (ge, ":highest_honor", 3),
        (else_try),
            #the player is a vassal of one of the initial kingdoms
            (is_between, "$players_kingdom", npc_kingdoms_begin, npc_kingdoms_end),
            (val_max, ":highest_honor", 1),
            (eq, "$player_has_homage", 1),#<- can fail
            (val_max, ":highest_honor", 2),
        (try_end),

        (try_begin),
           (ge, ":highest_honor", 3),
           (str_store_string, s0, "str_dplmc_your_highness"),
        (else_try),
           (eq, ":highest_honor", 2),
           (str_store_string, s0, "str_dplmc_my_lordlady"),
        (else_try),
           (str_store_string, s0, "str_dplmc_sirmadam"),
        (try_end),

		  ##Special cases
        (try_begin),
           (lt, "$sneaked_into_town", 1),
		     (is_between, "$g_talk_troop", companions_begin, companions_end),
			  (ge, ":highest_honor", 1),
			  (neg|troop_slot_eq, "$g_talk_troop", slot_troop_met, 0),
			  (this_or_next|neg|troop_slot_eq, "$g_talk_troop", slot_troop_occupation, slto_inactive),
			     (neg|troop_slot_eq, "$g_talk_troop", slot_troop_playerparty_history, 0),
		     (neg|troop_slot_eq, "$g_talk_troop", slot_troop_playerparty_history, dplmc_pp_history_nonplayer_entry),			  
           (troop_get_slot, ":honorific", "$g_talk_troop", slot_troop_honorific),
           (ge, ":honorific", "str_npc1_honorific"),
			  (str_store_string, s0, ":honorific"),
		  (else_try),
		     (eq, ":highest_honor", 1),
			  (is_between, "$g_talk_troop", heroes_begin, heroes_end),
			  (str_store_string, s0, "str_dplmc_sirmadame"),
        (try_end),

        (assign, reg0, ":highest_honor"),
 	]),

and last. Thank you for giving Read it
 
lol one thing i dont understand about taleworlds is that they have 6 page long codes for something that should only be 6 words long.
All i did for customizable troops was copy and paste the "let me see your inventory" for the heroes dialog into the regular non hero troops dialog and worked just fine.

 
CutContent said:
lol one thing i dont understand about taleworlds is that they have 6 page long codes for something that should only be 6 words long.
All i did for customizable troops was copy and paste the "let me see your inventory" for the heroes dialog into the regular non hero troops dialog and worked just fine.
That changes the equipment of all troops of that type, which poses a huge issue for game balance.
 
Back
Top Bottom