SP Tutorial Module System Manage Garrison in a Village

Users who are viewing this thread

Tinerfe

Recruit
That is very silly.
Just do that.
1º Open module_game_menus.py
2º Find this line:
Code:
],"Door to the village center."),

3º Paste it under that
Code:
 ("village_station_troops",
      [	  
		(party_get_slot, ":town_lord", "$current_town", slot_town_lord),
	    (str_clear, s10),
		  
	    (assign, ":player_can_draw_from_garrison", 0), 
		(try_begin), #option 1 - player is town lord
		  (eq, ":town_lord", "trp_player"),
		  (assign, ":player_can_draw_from_garrison", 1),
		(else_try), #option 2 - town is unassigned and part of the player faction
		  (store_faction_of_party, ":faction", "$g_encountered_party"),
		  (eq, ":faction", "fac_player_supporters_faction"),			
		  (neg|party_slot_ge, "$g_encountered_party", slot_town_lord, active_npcs_begin), #ie, zero or -1

		  (assign, ":player_can_draw_from_garrison", 1),
		(else_try), #option 3 - town was captured by player
		  (lt, ":town_lord", 0), #ie, unassigned
		  (store_faction_of_party, ":village_faction", "$g_encountered_party"),
		  (eq, "$players_kingdom", ":village_faction"),
		  
		  (eq, "$g_encountered_party", "$g_castle_requested_by_player"),

		  (str_store_string, s10, "str_retrieve_garrison_warning"),
		  (assign, ":player_can_draw_from_garrison", 1),
		(else_try),
		  (lt, ":town_lord", 0), #ie, unassigned
		  (store_faction_of_party, ":village_faction", "$g_encountered_party"),
		  (eq, "$players_kingdom", ":village_faction"),
		  
		  (store_party_size_wo_prisoners, ":party_size", "$g_encountered_party"),
		  (eq, ":party_size", 0),
			
		  (str_store_string, s10, "str_retrieve_garrison_warning"),
		  (assign, ":player_can_draw_from_garrison", 1),
		(else_try),
		  (party_slot_ge, "$g_encountered_party", slot_town_lord, active_npcs_begin),
		  (store_faction_of_party, ":village_faction", "$g_encountered_party"),
		  (eq, "$players_kingdom", ":village_faction"),
		  
		  (troop_slot_eq, "trp_player", slot_troop_spouse, ":town_lord"),		    

		  (assign, ":player_can_draw_from_garrison", 1),
		(try_end),

        (eq, ":player_can_draw_from_garrison", 1),
      ],
      "Manage the garrison {s10}",
      [
        (change_screen_exchange_members,1),
      ])

End.

You will find a new option in the "village menu" for store troops in it!
 
Keep it up.  I've been wondering how I'd go about doing all this for my own mod, but you've done most of the work already.  Gives me time now to look into the other million things I need to code.  Well done and thanks very much! :smile:
 
Hello, I tried implementing your code and it appears I have done something wrong :???: (Does it work for warband?)
When I build module it says this
Code:
Traceback (most recent call last):
  File "process_init.py", line 2, in <module>
    from process_operations import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\process_operations.py", line 22, in <module>
    from module_game_menus import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\module_game_menus.py", line 8473, in <module>
    (try_end),
TypeError: 'tuple' object is not callable
Traceback (most recent call last):
  File "process_global_variables.py", line 12, in <module>
    from process_operations import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\process_operations.py", line 22, in <module>
    from module_game_menus import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\module_game_menus.py", line 8473, in <module>
    (try_end),
TypeError: 'tuple' object is not callable
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
Traceback (most recent call last):
  File "process_map_icons.py", line 6, in <module>
    from process_operations import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\process_operations.py", line 22, in <module>
    from module_game_menus import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\module_game_menus.py", line 8473, in <module>
    (try_end),
TypeError: 'tuple' object is not callable
Exporting faction data...
Exporting item data...
Traceback (most recent call last):
  File "process_items.py", line 66, in <module>
    from process_operations import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\process_operations.py", line 22, in <module>
    from module_game_menus import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\module_game_menus.py", line 8473, in <module>
    (try_end),
TypeError: 'tuple' object is not callable
Exporting scene data...
Traceback (most recent call last):
  File "process_scenes.py", line 15, in <module>
    from process_operations import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\process_operations.py", line 22, in <module>
    from module_game_menus import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\module_game_menus.py", line 8473, in <module>
    (try_end),
TypeError: 'tuple' object is not callable
Exporting troops data
Exporting particle data...
Traceback (most recent call last):
  File "process_scene_props.py", line 7, in <module>
    from process_operations import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\process_operations.py", line 22, in <module>
    from module_game_menus import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\module_game_menus.py", line 8473, in <module>
    (try_end),
TypeError: 'tuple' object is not callable
Traceback (most recent call last):
  File "process_tableau_materials.py", line 8, in <module>
    from process_operations import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\process_operations.py", line 22, in <module>
    from module_game_menus import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\module_game_menus.py", line 8473, in <module>
    (try_end),
TypeError: 'tuple' object is not callable
Traceback (most recent call last):
  File "process_presentations.py", line 8, in <module>
    from process_operations import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\process_operations.py", line 22, in <module>
    from module_game_menus import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\module_game_menus.py", line 8473, in <module>
    (try_end),
TypeError: 'tuple' object is not callable
Exporting party_template data...
Traceback (most recent call last):
  File "process_parties.py", line 4, in <module>
    from module_game_menus import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\module_game_menus.py", line 8473, in <module>
    (try_end),
TypeError: 'tuple' object is not callable
Exporting quest data...
Exporting info_page data...
Traceback (most recent call last):
  File "process_scripts.py", line 7, in <module>
    from process_operations import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\process_operations.py", line 22, in <module>
    from module_game_menus import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\module_game_menus.py", line 8473, in <module>
    (try_end),
TypeError: 'tuple' object is not callable
Traceback (most recent call last):
  File "process_mission_tmps.py", line 8, in <module>
    from process_operations import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\process_operations.py", line 22, in <module>
    from module_game_menus import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\module_game_menus.py", line 8473, in <module>
    (try_end),
TypeError: 'tuple' object is not callable
Traceback (most recent call last):
  File "process_game_menus.py", line 5, in <module>
    from module_game_menus import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\module_game_menus.py", line 8473, in <module>
    (try_end),
TypeError: 'tuple' object is not callable
Traceback (most recent call last):
  File "process_simple_triggers.py", line 5, in <module>
    from process_operations import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\process_operations.py", line 22, in <module>
    from module_game_menus import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\module_game_menus.py", line 8473, in <module>
    (try_end),
TypeError: 'tuple' object is not callable
Traceback (most recent call last):
  File "process_dialogs.py", line 9, in <module>
    from process_operations import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\process_operations.py", line 22, in <module>
    from module_game_menus import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\module_game_menus.py", line 8473, in <module>
    (try_end),
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 "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\process_operations.py", line 22, in <module>
    from module_game_menus import *
  File "C:\Program Files\Mount&Blade Warband1\Modules\New Elgante\New Elgante So
urce Code\module_game_menus.py", line 8473, in <module>
    (try_end),
TypeError: 'tuple' object is not callable
Exporting postfx_params...

______________________________

Script processing has ended.
Press any key to exit. . .
 
The raided village (and its garrison) is quick-attached to the encounter in Native already. Note, however, that all villages will be raided at the same rate. In addition, you'll want to call (party_set_flags, ":village_no", pf_hide_defenders, 0), at some point.
 
Crossbow Joe said:
Does anybody know what I did wrong? :???:

There should be a comma after the last "])"

Should be:
[       
  (change_screen_exchange_members,1),
]),
 
I'd add a check if the village has a manor built, so only manor-ed villages can be used to garrison people in.
Otherwise, nice code. I'd begun making it rather differently in TBS at first, but I'll use this now. :smile:
 
Crossbow Joe said:
Thanks alot! It still amazes me how many errors can occur from a simple mistake.
I'll add you to the credits :grin:

Cool.  You're very welcome.  What credits?
 
Is it possible to make this menu only show up in a specific village by changing the first line to village_2_station_troops or something like that? :smile:

(excuse my english, it is not my first language)
 
Is this of any use (yes, necro, but it's the main topic with the code so I ask here)?
I have almost 200 Soldiers (max upgraded) stationed at a village, the next thing I see is: a Lord with 50 non-max-upgraded soldiers raided and looted my village. After it was looted, I could still manage the garrison which has not changed in numbers.

The only benefit I see is: You can place as many soldiers as you like while having not to pay for them (they don't appear in the weekly budget report).
 
The population of a village garrison really isn't taken into account for village raids in auto-calc unfortunately. This code is a convenience allowing for player that don't own a walled center to have a drop-off point for troops, not paying for them is a side effect of it being a village and not a town or castle.
 
Back
Top Bottom