SP Tutorial AI [GUIDE] Fix the indictment death Spiral

Users who are viewing this thread

It is a common sight in Warband: Sooner or later a lord gets thrown out of his faction, joins another one only to be indicted again few days thereafter.
... I have found that all lords befallen by this sad fate share two interesting characteristics:
1) They hold no fiefs. No wonder, those being stripped on indictment. This makes them more likely to raise controversy.
2) They have a controversy of >90. Probably due to 1). And this makes them ineligible for new fiefs. Which causes 1) to persist.
Another interesting point is that a lord loses his party on indictment, which has him suffer both respawn and buildup time before he actually has a chance to work on rising once more.

Experimentally, I have modified script_indict_lord_for_treason with two minor tweaks and it seems to have done the trick, so to write:
Code:
    (troop_set_slot, ":troop_no", slot_troop_controversy, 0),
Code:
    (troop_get_slot, ":led_party", ":troop_no", slot_troop_leaded_party),
    (try_begin),
      (party_is_active, ":led_party"),
      (neq, ":led_party", "p_main_party"),
      (party_set_faction, ":led_party", ":new_faction"),
    (try_end),
Unfortunately, my playtime is rather limited, so I am not totally sure it is enough. Within ~400 ingame days the problem has so far not resurfaced, which is most reassuring though.

Detailed deployment instruction:

Seek for "#Indictments, cont: Remove party" in module_scripts.py.

The first code block goes right above this line.

The code block that is already in place directly below this line must be replaced. If you want a minimal solution which may or may not cause problems that you can help me find, replace with the second code block from the beginning of this post.
If you just want to play it save, replace instead with this:
Code:
    (troop_get_slot, ":led_party", ":troop_no", slot_troop_leaded_party),
    (try_begin),
      (party_is_active, ":led_party"),
      (neq, ":led_party", "p_main_party"),
      (party_set_faction, ":led_party", ":new_faction"),
      # addition to minimal: detaches lord's party from anything it is currently attached to, increases chance of flight
      (party_get_attached_to, ":anything", ":led_party"),
      (ge, ":anything", 0), # center, fight, whatever else one can be attached to; assumes "nothing" be '-1'
      (party_detach, ":led_party"),
    (try_end),
To help out the lord even more, use JuJu70's variant, which additionally teleports the lord to safety (you may see a lord disappear on the world map, if you are nearby when he is indicted; this is already the case with the vanilla script, however):
Code:
    (troop_get_slot, ":led_party", ":troop_no", slot_troop_leaded_party),
    (try_begin),
      (party_is_active, ":led_party"),
      (neq, ":led_party", "p_main_party"),
      (party_set_faction, ":led_party", ":new_faction"),
      # addition to minimal: teleports lord's party to town or castle of new faction, guarantees flight
      (party_detach, ":led_party"), # assumes that party_detach does not fail if party not attached to anything
      (call_script,"script_cf_select_random_walled_center_with_faction", ":new_faction", -1),
      (party_relocate_near_party, ":led_party", reg0, 2),
    (try_end),
 
Great idea, esp about reseting the controversy.
I think changing the party's faction can produce troubles. If the lord's party is in the heart of his old faction's land when he does the treason then you will put him in danger surounding by unfriendly lords immediately. It will be worse for him if his party is at any town belong to other lord from his old faction. Removing his party is safer as he will respawn at friendly setlemen in 72 hours. May be you can save his party's member, mark him as an indicted lord, then adding them back to his respawned party later.
 
I admit that I followed the route of equal opportunities here - this is what happens for the player, thus it happens for all.
... Checking for center attachment is a good idea though, I guess. If only I could observe what happens if the party is in town when its lord gets indicted.
Code:
    (troop_get_slot, ":led_party", ":troop_no", slot_troop_leaded_party),
    (try_begin),
      (party_is_active, ":led_party"),
      (neq, ":led_party", "p_main_party"),
      (party_set_faction, ":led_party", ":new_faction"),
      # Is this actually necessary? They will leave sooner or later and indictment messages tend not to be followed
      # by defeat messages for the same lord, so on average, an indicted lord apparently does fine without.
      # Needs observation in the act, meaning of a lord within a center who is then indicted.
      # possible alternative: auto-imprisonment; Cannot be that everyone always escapes!
      (party_get_attached_to, ":anything", ":led_party"),
      (ge, ":anything", 0), # center, fight, whatever else one can be attached to; assumes "nothing" be '-1'
      (party_detach, ":led_party"),
    (try_end),
 
phantom96 said:
[W]hich files do I need to edit?
script_indict_lord_for_treason is in module_scripts.py.
Seek for "#Indictments, cont: Remove party", add the first code block immediately above this line and replace the block below it with the second one (or with the one from third post).
 
dunde said:
Great idea, esp about reseting the controversy.
I think changing the party's faction can produce troubles. If the lord's party is in the heart of his old faction's land when he does the treason then you will put him in danger surounding by unfriendly lords immediately. It will be worse for him if his party is at any town belong to other lord from his old faction. Removing his party is safer as he will respawn at friendly setlemen in 72 hours. May be you can save his party's member, mark him as an indicted lord, then adding them back to his respawned party later.

You just relocate the lords party to the safe place
Code:
	(try_begin),
		(party_is_active, ":led_party"),
		(neq, ":led_party", "p_main_party"),
		(party_set_faction, ":led_party", ":new_faction"),
                (party_detach, ":led_party"),
		(call_script,"script_cf_select_random_walled_center_with_faction", ":new_faction", -1),
		(assign, ":center", reg0),
		(party_relocate_near_party, ":led_party", ":center", 2),
	(try_end),
 
Do you not think that go a little far? If they can teleport, why do they fight with swords!
... Besides, you might want to check for the player in this case, as the code piece in question will affect the player if this script is called for him. Or can I haz beamy deff gun too?
 
LordZsar1 said:
Do you not think that go a little far? If they can teleport, why do they fight with swords!
... Besides, you might want to check for the player in this case, as the code piece in question will affect the player if this script is called for him. Or can I haz beamy deff gun too?
(neq, ":led_party", "p_main_party"),
 
Nice idea... it's kida' crazy in my mod right now everyone starts deserting immediately after game start and end up joining they archenemies' faction. So don't mind if I use your code and credit you for it :smile:
 
Dawiduh said:
[...] everyone starts deserting immediately [...]
If they defect, this will probably not help much.
Another approach is adivsable then, as a lord who takes his fiefs and runs actually should keep his controversy. And, well, he will keep his party anyway.
 
right, i need to keep an eye on that and see exactly what is happening

when a faction conquers another faction's castle i see the banner above it doesn't change. where can I find the script that takes care of conquest? i looked in module_scripts.py but i missed it so far.
 
A bit of a maze, this part of code, eh?
I will have a l- Sweet mother of god! Bad coding practices and the "Too many cooks"-syndrome had a child - and it is ugly!

... Scarred for live, but if the lord actually loses the center, then the lines you look for are in module_scripts.py, in "script_give_center_to_lord" and "script_give_center_to_faction_aux". It is called with "stl_unassigned" to set the banner to '0' by use of "party_set_banner_icon".
All other calls to "party_set_banner_icon" have a check in place and cannot cause removal, are thus unrelated.
- As this works in vanilla, mayhap you have to look around a bit. Does the former owner actually lose the center?

You might want to open a new thread for this.
 
Back
Top Bottom