ok, I'm trying to integrate 'Kingdom Management' into the star wars mod. I used Highlander's code from Age of Machinery for version 0.960 as a base, and it was easy to integrate. I did have a few random questions if people who have done this (or can read python better than I can) could give some feedback...
it seems the activate_deactivate_player_faction in module_scripts.py changed slightly between 0.960 and 1.x. The lines marked as "#only existed in 0.960 code" did not exist in 1.x. But I wasn't sure if they were necessary for kingdom management so I left them in. This is how I ended up coding it, but I'd be curious to compare it against somebody else who integrated this mod.
to test kingdom management I ended up adding the following in game_start in module_scripts so I started with some towns.
However, when I enter the town all I see is hired guards (my default troop) as the 'town guards'. Even if I go into Kingdom Management and change my culture, the guards in the towns don't change. I'm very confused about the change_culture game menu and what it does...
a) should it be "slto_kingdom_hero" or slot_kingdom_hero? "slto_" seems to be used in other parts of the code but I was wondering if it was a spelling error... answered below
b) the original code sets the slot_faction_culture to fac_kingdom_1 but shouldn't it be fac_culture_1 ? Maybe I'm wrong since I never understood the difference between faction_1 & culture_1 tho, since they are both in module_factions.py?!?!
c) It seems like it switches my new recruited lords to be part of my player faction?
d) it doesn't seem to do anything to change the faction or culture of the towns? It seems like I would have to add some new code to also switch the center_culture of the towns if they were owned by player faction (or player_supporters_faction, don't know what the difference is). However, I tried this code above and it didn't do anything when I switched my culture and entered the town it still used the default hired guard troops...
it seems that when I enter a town the code should be calling something like this, so I'm guessing the $g_encountered_party_faction isn't being set correctly by this change_culture game menu?
e) should I be calling "script_activate_deactivate_player_faction" (or something like that) in this game menu to reset the towns or something?
assuming I can get the above working, then long term I'd like to add more cultures. so I believe I'd need to:
1) create more cultures in module_factions.py
2) in game start setup the slot_faction_guard/deserter/reinforcements, etc.
3) add a new culture to this kingdom management menu
anyway, my main issue is "change_culture" game menu doesn't seem to do as much as I want. Maybe this is how I am testing, by using give_center_to_lord at the start, but I think I need to do some additional coding in order to also switch the faction or culture of player or player supporter owned towns, but I'm not sure why my new code isn't working. any suggestions would be appreciated.
it seems the activate_deactivate_player_faction in module_scripts.py changed slightly between 0.960 and 1.x. The lines marked as "#only existed in 0.960 code" did not exist in 1.x. But I wasn't sure if they were necessary for kingdom management so I left them in. This is how I ended up coding it, but I'd be curious to compare it against somebody else who integrated this mod.
Code:
#script_activate_deactivate_player_faction
# INPUT: arg1 = last_interaction_with_faction
# OUTPUT: none
("activate_deactivate_player_faction",
[
(store_script_param, ":last_interaction_with_faction", 1),
(try_begin),
(assign, ":has_center", 0),
(try_for_range, ":cur_center", centers_begin, centers_end),
(store_faction_of_party, ":cur_center_faction", ":cur_center"),
(eq, ":cur_center_faction", "fac_player_supporters_faction"),
(assign, ":has_center", 1),
(try_end),
#own kingdom start-----------------------------------
(assign,":player_center",-1), #only existed in 0.960 code
(try_for_range, ":cur_center", walled_centers_begin, walled_centers_end), #only existed in 0.960 code
(store_faction_of_party, ":cur_center_faction", ":cur_center"), #only existed in 0.960 code
(eq, ":cur_center_faction", "fac_player_supporters_faction"), #only existed in 0.960 code
(assign,":player_center",":cur_center"),
(try_end), #only existed in 0.960 code
#own kingdom end-----------------------------------
(try_begin),
(eq, ":has_center", 1),
(neg|faction_slot_eq, "fac_player_supporters_faction", slot_faction_state, sfs_active),
(faction_set_slot, "fac_player_supporters_faction", slot_faction_state, sfs_active),
(faction_set_slot, "fac_player_supporters_faction", slot_faction_leader, "trp_player"),
#own kingdom start-----------------------------------
(try_begin),
(gt,":player_center",0),
(val_sub,":player_center","p_town_1"),
(val_add,":player_center","str_center_1_kingdom"),
(str_store_string,s1, ":player_center"),
(faction_set_name, "fac_player_supporters_faction", "@{s1}"),
(faction_set_slot, "fac_player_supporters_faction", slot_faction_culture, ":last_interaction_with_faction"),
(else_try),
#own kingdom end-----------------------------------
(str_store_faction_name, s1, ":last_interaction_with_faction"),
(faction_set_name, "fac_player_supporters_faction", "@{s1} Rebels"),
#own kingdom start-----------------------------------
(faction_set_slot, "fac_player_supporters_faction", slot_faction_culture, "fac_kingdom_2"),
(try_end),
#own kingdom end-----------------------------------
(faction_set_color, "fac_player_supporters_faction", 0xAAAAAA),
(assign, "$players_kingdom", "fac_player_supporters_faction"),
(assign, "$g_player_banner_granted", 1),
(call_script, "script_store_average_center_value_per_faction"),
(call_script, "script_update_all_notes"),
(call_script, "script_add_notification_menu", "mnu_notification_player_faction_active", 0, 0),
(else_try),
(eq, ":has_center", 0),
(faction_slot_eq, "fac_player_supporters_faction", slot_faction_state, sfs_active),
(le, "$supported_pretender", 0),
(faction_set_slot, "fac_player_supporters_faction", slot_faction_state, sfs_inactive),
(faction_set_slot, "fac_player_supporters_faction", slot_faction_leader, "trp_player"),
(assign, "$players_kingdom", 0),
(assign, "$players_oath_renounced_against_kingdom", 0),
(assign, "$players_oath_renounced_given_center", 0),
(assign, "$players_oath_renounced_begin_time", 0),
(call_script, "script_store_average_center_value_per_faction"),
(call_script, "script_update_all_notes"),
(call_script, "script_add_notification_menu", "mnu_notification_player_faction_deactive", 0, 0),
(try_end),
(try_end),
]),
to test kingdom management I ended up adding the following in game_start in module_scripts so I started with some towns.
Code:
(call_script, "script_give_center_to_lord", "p_town_1", "trp_player", 0),
(call_script, "script_give_center_to_lord", "p_town_2", "trp_player", 0),
(call_script, "script_give_center_to_lord", "p_town_3", "trp_player", 0),
(call_script, "script_give_center_to_lord", "p_town_4", "trp_player", 0),
However, when I enter the town all I see is hired guards (my default troop) as the 'town guards'. Even if I go into Kingdom Management and change my culture, the guards in the towns don't change. I'm very confused about the change_culture game menu and what it does...
Code:
("change_culture",0,
"Choose a culture:",
"none",
[],
[
("empire", #SW modified
[],"Galactic Empire culture", #SW modified
[
#(faction_set_slot, "fac_player_supporters_faction", slot_faction_culture, "fac_kingdom_1"),
(faction_set_slot, "fac_player_supporters_faction", slot_faction_culture, "fac_culture_1"), #SW modified, shouldn't it be culture_1 instead?
(try_for_range,":lord","trp_reserved_knight_1","trp_reserved_knight_end"), #SW modified
(troop_slot_eq, ":lord", slot_troop_occupation, slto_kingdom_hero),
(troop_set_slot, ":lord", slot_troop_original_faction,"fac_kingdom_1"),
(try_end),
#------------------------------------------------------------------------------------
#SW - new code to try and fix town guards, reinforements, and other things?
(try_for_range, ":center_no", centers_begin, centers_end),
(store_faction_of_party, ":center_faction", ":center_no"),
(try_begin),
(eq, ":center_faction", "fac_player_supporters_faction"), #maybe I need to check player_faction instead? or do a this_or_next ?
(party_set_slot, ":center_no", slot_center_culture, "fac_culture_1"),
(try_end),
(try_end),
#------------------------------------------------------------------------------------
(jump_to_menu, "mnu_own_kingdom"),
]),
b) the original code sets the slot_faction_culture to fac_kingdom_1 but shouldn't it be fac_culture_1 ? Maybe I'm wrong since I never understood the difference between faction_1 & culture_1 tho, since they are both in module_factions.py?!?!
c) It seems like it switches my new recruited lords to be part of my player faction?
d) it doesn't seem to do anything to change the faction or culture of the towns? It seems like I would have to add some new code to also switch the center_culture of the towns if they were owned by player faction (or player_supporters_faction, don't know what the difference is). However, I tried this code above and it didn't do anything when I switched my culture and entered the town it still used the default hired guard troops...
it seems that when I enter a town the code should be calling something like this, so I'm guessing the $g_encountered_party_faction isn't being set correctly by this change_culture game menu?
Code:
(faction_get_slot, ":troop_prison_guard", "$g_encountered_party_faction", slot_faction_prison_guard_troop),
e) should I be calling "script_activate_deactivate_player_faction" (or something like that) in this game menu to reset the towns or something?
assuming I can get the above working, then long term I'd like to add more cultures. so I believe I'd need to:
1) create more cultures in module_factions.py
2) in game start setup the slot_faction_guard/deserter/reinforcements, etc.
3) add a new culture to this kingdom management menu
anyway, my main issue is "change_culture" game menu doesn't seem to do as much as I want. Maybe this is how I am testing, by using give_center_to_lord at the start, but I think I need to do some additional coding in order to also switch the faction or culture of player or player supporter owned towns, but I'm not sure why my new code isn't working. any suggestions would be appreciated.