some questions for people who have integrated Kingdom Management from AoM...

Users who are viewing this thread

HokieBT

Grandmaster Knight
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.

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"),
    ]),

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?
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.

 
I not sure about everything but I do know that slto_kingdom_hero isn't a typo the slto stands for slot troop occupation.  As for the rest I haven't tried to implement kingdom management into my mod yet.  Good luck with the rest though.
 
Berserker Pride said:
I not sure about everything but I do know that slto_kingdom_hero isn't a type the slto stands for slot troop occupation.  As for the rest I haven't tried to implement kingdom management into my mod yet.  Good luck with the rest though.
thanks for the info, I'll update the first post
 
Im not really an advanced coder.. but well, I have a working Kingdom Management.. here is my very slightly modified code for the culture part:

("danish",
    [],"Danish culture",
    [
          (faction_set_slot, "fac_player_supporters_faction", slot_faction_culture, "fac_culture_1"),
          (faction_set_slot, "fac_player_supporters_faction",  slot_faction_tier_1_troop, "trp_danish_recruit"),
          (try_for_range,":lord","trp_reserved_knight_1","trp_kingdom_1_pretender"),
            (troop_slot_eq, ":lord", slot_troop_occupation, slto_kingdom_hero),
            (troop_set_slot, ":lord", slot_troop_original_faction,"fac_kingdom_1"),
          (try_end),
          (jump_to_menu, "mnu_own_kingdom"),
I am not sure if the slot_faction_tier_1_troop is needed to be there, just did it to be sure that you get recruits from your villages...

the only problem with this, is that sometimes does the lords show up with no army.. Im not sure why, becouse when you "give" the player_supporters_faction a culture. Your lords should automaticly be given the party_template the culture has.. maybe its happening when you choose a culture after recruiting the lord(s)..

trying to answer your questions:

a) I'm not sure about that, apparently it works fine

b) As you can see did I had to change it to "fac_culture" instead of "fac_kingdom"

c) It does, when you recruit a lord it swichtes one of 20 neutral lords to your faction..

d) I'm not sure what you mean here, if you have added things like recruiting in towns i cant help you..


hope that was somewhat understandable..and usefull for that sake.. it probadly was'nt :razz:


EDIT: the diffrence beetween culture and kingdom is that the culture decides which troops, guards, deserters etc the kingdom you assign the culture to will have.. while a kingdom, only is a kingdom.. if you add a kingdom without a culture it wont have any recruits in its villages, their lords wont spawn with any troops in their armies etc..
 
Do a search for culture_1 in scripts, you will see how they implement the troop tiers.  Just set a culture (such as culture_player, if you want it to be special) and populate the slots like the other cultures.  Should then give you the proper troops gaurds, I think.  I have only slightly touched on this before working on a project with Naglfaar
 
thanks for the feedback guys.  My main thing is I want to be able to do a few things when you switch cultures.  I'm just not good enough reading python code to make this all work.....

a) switch the troops your lords recruit to their armies.

The change_culture menu switches your recruited lord's original_faction
Code:
  (troop_set_slot, ":lord", slot_troop_original_faction,"fac_kingdom_1"),

The "cf_reinforce_party" script adds troops to your knights army or garrisons.  But I don't understand the all the code in red....  It seems that if the knight was a "town_lord" it would get their original_faction (which would be kingdom_1 due to the code in change_culture above) so they would get the correct recruits.  But if they weren't a town_lord, or they were just a town garrison, then it would get the slot_center_original_faction which may not be kingdom_1 since it wasn't switched in change_culture the code above?

  # script_cf_reinforce_party
  # Input: arg1 = party_no,
  # Output: none
  # Adds reinforcement to party according to its type and faction
  ("cf_reinforce_party",
    [
      (store_script_param_1, ":party_no"),
     
      (store_faction_of_party, ":party_faction", ":party_no"),
      (party_get_slot, ":party_type",":party_no", slot_party_type),

#Rebellion changes begin:
      (try_begin),
        (eq, ":party_type", spt_kingdom_hero_party),
        (party_stack_get_troop_id, ":leader", ":party_no"),
        (troop_get_slot, ":party_faction",  ":leader", slot_troop_original_faction),

#            (this_or_next|is_between, ":party_faction", rebel_factions_begin, rebel_factions_end),
#            (faction_get_slot, ":target_faction", ":party_faction", slot_faction_rebellion_target),
#            (assign, ":party_faction", ":target_faction"),
#            (assign, ":party_faction", "fac_kingdom_1"),
      (try_end),
#Rebellion changes end

      (try_begin),
        (eq, ":party_faction", "fac_player_supporters_faction"),
        (party_get_slot, ":town_lord", ":party_no", slot_town_lord),
        (try_begin),
          (gt, ":town_lord", 0),
          (troop_get_slot, ":party_faction", ":town_lord", slot_troop_original_faction),
        (else_try),
          (party_get_slot, ":party_faction", ":party_no", slot_center_original_faction),
        (try_end),
      (try_end),

     
      (faction_get_slot, ":party_template_a", ":party_faction", slot_faction_reinforcements_a),
      (faction_get_slot, ":party_template_b", ":party_faction", slot_faction_reinforcements_b),
      (faction_get_slot, ":party_template_c", ":party_faction", slot_faction_reinforcements_c),


b) cruger had a good point about switching the default recruit at villages

I'll test out his suggestion, that should probably work

c) switch all the castle, town, and prison guard troops that appear in towns.  This doesn't seem to happen for me with the AoM Kingdom Management code.

As mentioned above, we reset the lords original_faction but don't seem to modify any of the town centers?
Code:
(troop_set_slot, ":lord", slot_troop_original_faction,"fac_kingdom_1"),

for example, if you "take a walk around a courtyard" you should see some prison guards.  But it seems like there is two problems with this that I have highlighted in red:

      ("castle_inspect", [
        (party_slot_eq,"$current_town",slot_party_type, spt_castle),
#          (this_or_next|ge, "$g_encountered_party_relation", 0),
#          (eq,"$castle_undefended",1),
          ],
#SW - modified menu
      #"Take a walk around the courtyard.",
  "Take a walk around the planet.",
      [
          (assign, "$talk_context", tc_town_talk),
         
          (party_get_slot, ":cur_castle_exterior", "$current_town", slot_castle_exterior),
          (modify_visitors_at_site,":cur_castle_exterior"),(reset_visitors),

          (try_begin),
            (neq, "$g_encountered_party_faction", "fac_player_supporters_faction"),
            (faction_get_slot, ":troop_prison_guard", "$g_encountered_party_faction", slot_faction_prison_guard_troop),

            (set_visitor, 24, ":troop_prison_guard"),
          (try_end),

1) there is a (neq, player_supporters_faction) I'd need to remove?

2) how does this code work?  What is in $g_encountered_party_faction and would that have gotten switched when I did the "change_culture" code?  I think it probably contains the party id (town or castle) and since that the towns or castles faction wasn't switched in the game menu I think this command will fail...
Code:
(faction_get_slot, ":troop_prison_guard", "$g_encountered_party_faction", slot_faction_prison_guard_troop),



anyway, maybe I'm making this more difficult then I need to be, but I understand python just enough to partially read it and get more confused....  It seems like I'd want to also switch the culture, faction, original_faction, etc of all player_faction towns/castles/villages but I'm not sure how to do that in the code.  I tried this but it didn't seem to make a difference between when I walked around town I either didn't see guards or they weren't specific troops for the faction I switched to....

        #------------------------------------------------------------------------------------
        #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),
        #------------------------------------------------------------------------------------


edit:  I probably just have to test all this stuff later tonight and start adding display_messages and debug code....  I was just hoping somebody had either already done this with Kingdom Management, or can read python code and tell me better what its trying to do, etc...
 
Back
Top Bottom